EPi find get all variants if search hit on product - find

A EPi find question coming up, We have WebProducts and WebVariants and when showing a simple product listing on the category page I'm showing the following result correctly
If a WebProduct doesn't have any variants - show the WebProduct on the result
If a WebProduct has variants - show the WebVariants and hide the WebProduct
But when I'm trying to use the same functionality for the site-search it gets complicated.
The WebProduct has a property named Brand while the WebVariants doesn't have that property. So when I search for "My brand" and I get a hit on a WebProduct that has WebVariants, it won't show the WebProduct because point 2 is true in that case.
I on the other hand don't want to show the product, but I want to get the variants for that product... It might sound confusing :grimacing:
I'll add a code snippet of the code that makes point 1 and 2 to work.
.SearchAndFilterFor(q)
.Filter(x =>
(x.MatchType(typeof(WebVariant))) |
(x.MatchType(typeof(WebProduct)) & ((WebProduct)x).HasVariants().Match(false)))```

I would say that you have a couple of options to choose from.
Either:
1: Change the way your variants are indexed so that they include some of the key info (in this case brand) that they currently lack and as such, appear in the search results.
OR
2: Just do the search for WebProduct and then loop through those results afterward to do the processing for ones that do/don't have variants.

Related

Using a List Box's user-choice as a Condition in LibreOffice Writer

I'm trying to make a form-fillable pdf where List Boxes will affect other parts of the sheet.
I have several Hidden Paragraphs in my document (hiding graphics, etc), and a List Box. I'd like to use the List Box choice as the Condition to dynamically hide and unhide the various Hidden Paragraphs.
Example: The user selects clicks on the List Box, and Cat, Dog, and Bird are listed. If the user selects "Dog" from the list, the paragraph with text and pictures of dogs is no longer hidden.
I get that I have to do Hide Paragraph if [List Box choice] != "Dog" as my Condition, I just can't figure out where to get the List Box choice. Feels like I hit a wall in searching for an answer or guide because I'm missing specific terminology (field? formula?).
I am actually trying to do the same thing, and I'm getting very frustrated by it. I developed a case management database for my law office (actually, it pretty much manages almost every aspect of the office at this point), but because we handle all kinds of different cases (criminal defense, civil litigation, probate, etc.) the information we need to track often varies. For instance, on criminal cases, we need to keep track of the sentencing guidelines scoring, the current offer from the prosecutor, prior convictions, and so on. For family law cases, we need to keep track of things like assets, parenting time schedules, etc. Putting all of these variable on one page at the same time gets very cumbersome very quickly, so I'm trying to set the form up so that when you select a case a "criminal defense", it shows the "Criminal Defense" portion of the page, and hides the "Family Law", "Civil Litigation", "Probate", and other portions.
The only way I could come up to do it was the create a variable (in this case, I called it "CaseType") and set the paragraphs to hide or be visible depending on what the variable is set to. This works great, except (a) it's awkward making users select the type of case it is for database purposes, and then making them select the type of case details to display in the form; and (more importantly) (b) the user has to type the required value of the variable into the dialog directly, which is a pain. I would much rather be able to have the type of sections that are displayed determined by the value of the case type in the database, or at the very list have the panels displayed in a dropdown list.
I came up with an idea to record a macro that would run when you pushed buttons--for example, press the "Criminal Case Panel" button and a script would run that selected the variable via double-click, entered the correct value in the dialog box, and then applied the new variable, but it seems that Writer will not let you record macros that change values in dialog boxes.
There is so much untapped potential in this aspect of the software; if the user variables could be set by forms--or if the "hidden" flags could be triggered to be hidden by the values of database variables--it would open up so many possibilities. Makes me wish I had the coding skills to work on this part of the software.
According to https://help.libreoffice.org/7.0/en-US/text/swriter/01/04090200.html, you can set up a database for Writer conditions. It looks like this would work with LibreOffice Base, where forms with list boxes can be created.
However, if you are trying to use values from a list box in a standalone Writer template or other document, then looking at that link, it does not seem possible. Writer conditions are restricted to document metadata, not the contents of the document.
One solution is to write a macro that pops up a dialog with a list box, and then when the dialog is closed, modify the Writer document based on the selected values. LibreOffice has a dialog development front end to help you set this up, and then you would need to write code to execute the dialog and do the changes. See https://www.pitonyak.org/oo.php for help writing the necessary code.

Visio ShapeSheet ShapeData: keep two rows in sync

I have two Shape Data rows for a Shape's ShapeSheet:
Shape Data Label Prompt Type Format Value Invisible
Prop.Type "Type" "" 4 "Alpha;Beta;Gamma;Delta;Epsilon;Zeta;Eta;Theta;Iota;Kappa" INDEX(4,Prop.Type.Format) False
Prop.Abbrev "Abbrev" No Formula 4 "A;B;G;D;E;Z;E;T;I;K" INDEX(4,Prop.Abbrev.Format) True
The way I intent to use this is to have the user select the Type, say Epsilon, and then have the Abbrev automatically switch to the corresponding value in the Prop.Abbrev.Format.
Note: the values used here are placeholders for the actual values for my application, which are not shown here so they don't distract from the real answer I need, how to keep the selections in sync when the first one is chosen or changed.
Thanks for any help you can give!
I don't have Visio on this machine, so I am unable to copy and paste a working solution. The approach gets a little complicated, but extremely flexible.
Save your lists in the User section, rather than Prop - this then becomes underlying data for use in properties. If you are using a master stencil then this also helps with managing the fields.
You can now store an index in your data as well - this index points to the appropriate values in your arrays. You can use Actions and side menus to set the index which, when referenced properly, means you can have the full name and/or abbreviation in the side menu and the ShapeSheet does all the work underneath.
The functions you want to look at are:
Index (e.g. INDEX(1,User.Type) will return "Beta". (0-based)
Lookup (e.g. LOOKUP("D", User.Abbrev) will return "3". (0-based)
GetAtRef
SetAtRef
SetAtRefExpr
SetF
I had a similar business problem which relied on setting a background colour based on the value of shape data. Your final solution could end up including formulas like this: =SETF(GetRef(Prop.Type),"GUARD(INDEX(LOOKUP(Prop.X,Prop.X.Format),User.Type))").
For more in-depth discussion - check out https://superuser.com/questions/1277331/fillforegnd-in-shapesheet-using-wrong-data and the extended discussion at http://visguy.com/vgforum/index.php?topic=8205.15 - the latter link also includes an example file with working shapesheets (well, working to the extent that they exposed my problem).

TYPO3 meta description - Use closest

I have set the description meta using:
page.meta.description.field = description
Can I make it so child pages use the description from the closest page that has one set?
So if the root page has description1 then all sub-pages use it, unless a sub-page has it's own description2 in which case it and any sub-pages of it would use description2 and so on...
two parts:
in your typoscript:
page.meta.description.data = levelfield:-1, description, slide
in your Install-Tool add the field to the fields which should slide:
$GLOBALS['TYPO3_CONV_VARS']['FE']['addRootLineFields'] = 'description';
added:
aside from straight slide to first non empty entry, you also have options to collect all the entries along the rootpath:
.slide If set and no content element is found by the select command, the rootLine will be traversed back until some content is found.
Possible values are "-1" (slide back up to the siteroot), "1" (only the current level) and "2" (up from one level back). Use -1 in combination with collect:
.slide.collect: (integer /stdWrap) If set, all content elements found on the current and parent pages will be collected. Otherwise, the sliding would stop after the first hit. Set this value to the amount of levels to collect on, or use "-1" to collect up to the siteroot.
.slide.collectFuzzy: (boolean /stdWrap) Only useful in collect mode. If no content elements have been found for the specified depth in collect mode, traverse further until at least one match has occurred.
.slide.collectReverse: (boolean /stdWrap) Reverse order of elements in collect mode. If set, elements of the current page will be at the bottom.
You should not do this - you will get a bunch of error messages in the google webmaster tool complaining about duplicate meta tags. Google dont like this ... it is a kind of duplicate content.
Watch this video from google evangalist Matt Cutts: http://searchengineland.com/googles-matt-cutts-dont-duplicate-your-meta-descriptions-177706
"In short, it is better to let Google auto-create snippets for your pages versus having duplicate meta descriptions."

How does one get the total number of slides?

In Articulate's Storyline product, how does one retrieve the total number of slides (or pages) in a storyfile or project?
There's not much documentation so it's kind of hard to figure out how to query common environment values like this. If we can get the total number of slides then we don't have to manually set a value for it.
One must manually set and update a variable to store the number of slides.
The most lengthy conversation on the matter seems to be found here at the Articulate forums.
In that thread the users and staff describe the need to manually define such a variable.
I asked the question on the official forum more directly here, and so far have not received a response.
Another poster at that forum mentioned using PHP to solve this problem, but unfortunately we can't add the requirement of PHP to the final product. I'm sure some server side language tricks might be used to solve this issue, but that also adds the dependency of a particular server-side language.
The Answer Mark gave is correct. So if you want to track the number of question slides in a quiz you would either hard code the value in a variable such as totalQuestions, or increment it as you go through each slide using adjust variable trigger. To call that value and display it on screen you would just add it to a text field and surround it with "%".
EG. "You have answered %Results.ScorePoints% out of %totalQuestions% questions correctly."
I find it rather pointless to hard code it since it's just as easy to put the value in the text field at the end. Using the increment method seems more logical because then you can add more question slides without having to adjust the variable or results screen each time.
I usually load frame.xml, browse for all slidelink tags and sort all slides by their Id.
Usually you get something like slideid=_player.5xoxGTW6QCh.6bmeRt3tCqP, where 5xoxGTW6QCh is the scene id and 6bmeRt3tCqP is the slide id. displaytext also gives you the slide title.
If you browse for slidetranscript and match the Id for each transcript you also get the slide notes.
Articulate 360 now has an internal (Built-in) variable for this and other counts. See Project.TotalSlides and Menu.TotalSlides
See https://community.articulate.com/series/articulate-storyline-360/articles/storyline-360-add-slide-numbers

MS Word 2007 - How to set up placeholder text to mimic text but not formatting

I'm probably biting off more than I can chew with this particular problem, but I'll try to be as specific as possible in case it's within my scope. Disclaimer: I'm not terribly experienced with MS Word, beyond simple data entry/some formatting, and I have absolutely zero experience working with macros or VBasic. Unfortunately, I'm afraid the solution to my problem will come in the form of one of those last two.
THE GOAL:
What I want to do is to have placeholder text throughout my template document that will change content but not formatting when the first instance of it is changed. Basically, I'm writing a template for support manuals for a software suite. Each app has certain similar features like the menu bar, data entry screen, diagnostic log screen, transaction history, etc., so I am pre-writing those sections and using placeholders when I need to insert certain app specific properties.
I started off using the Insert->Quick Parts->Document Property->Subject tool which I used as a placeholder for the app name. I set the Property to [Subject] and then used Insert->Quick Parts->Field->Subject throughout the document, wherever I needed to include the app name. This worked fine in this case because the app name will always be capitalized. I simply change the text in the first [Subject] (which is content controlled) and update the fields throughout the document, and they all match nicely, easy-peasy, work done, go home and drink beer, right?
Not quite.
Our software handles part tracking via scanners and SQL Server, so while the interface and menu in the apps remains largely unchanged, the parts they track change from app to app. Because of this, I need to change the part name when I reference it within the text of the manuals; for example, if I'm working in ToiletPap.app and our TP is tracked by the roll, I need every mention of [Component] to be changed to roll. If I'm working in LightBulbs.app, I need [Component] to say bulb.
My first efforts went toward creating a custom doc property called Component using the Advanced tab under the Document Properties dropmenu. I then created a plaintext content control around my first [Component] titled Component and made my next [Component] a field with modified code: {COMPONENT * MERGEFORMAT}. This comes from copying what I can find when [Subject] works. This didn't work at all; updating the text in the first CC doesn't change the Content doc prop, and my fields return "!Undefined Bookmark, COMPONENT".
I got close to what I need by using the [Comments] doc property, set initially to [Component]. I used it just like [Subject], but (this is when I realized that capitalization was going to be an issue) when I mention my [component] in-text, as often as not, I need to to be lowercase instead of upper.
I've looked on MS's forums and a few others as well as here on SO, and I can't find anyone who's trying to do the same thing, much less an answer to how. Please keep in mind when answering, it would be a great help to me if you would include step-by-step instructions on how to enter/implement the code you provide because, as I mentioned, I have no idea how to go about editing macros/VBasic for MS Word.
To restate and summarize my overall question: How can I use a placeholder that displays the text "[Component]" so that, when I change the first instance of [Component] to something else, say "hopper", every subsequent instance of [Component] is updated to hopper but maintains its current capitalization and formatting scheme?
Apologies for the length of the request, but I wanted to make sure I explained the situation as accurately as possible. Thanks in advance for your consideration and responses.
I managed to solve this one after a couple extra hours of tinkering. I didn't need macros or VBasic, either.
On the first instance of [component] I created a plain-text content control to act as a container (not a necessity, but it makes it look nicer. Will likely cause a problem eventually, but for now, it's working as intended) and bookmarked it. Then, for all other instances of [container] I selected each and used Insert->Quick Parts->Field->Ref with the following field code:
REF Text1 \*Lower
Where "Text1" is my bookmark and "*Lower" indicates all lower case. The *Lower can be replaced with *Upper or *FirstCap to indicate all upper case or capitalize the first letter respectively. Now, each field reflects the text of the first with the capitalization appropriate to each field's location within the document. Just like using the doc prop with [Subject], ^a -> f9 is needed to update all fields within the document.