Modx Revo Wayfinder: Add extra attribute to list item of current menu - modx

Ref: Wayfinder on Modx Revo
I've been searching extensively and couldn't find the answer.
I find a very tricky situation trying to output an extra attribute with the list item that wraps the current menu (the menu link on of the page you're currently in).
For example:
Instead of just this line..
<li class="current">This is the menu</li>
I want..
<li class="current" value="1">This is the menu</li>
see value="1"
I tried creating a chunk in relation with the &hereTpl parameter but apparently this parameter is no longer valid in Wayfinder Revo (or is it?).
I think another possible route is if there's a way for a conditional inside the &rowTpl to render the needed attribute only for the current menu but again another brick wall.
I also tried the [[+wf.attributes]] (on the list item tag in the template chunk and put the needed attribute in the Link attributes of all the the resources/documents assuming it's going to render only when the resource/document is "current" but then the attribute is just outputted to all the menu items.
Could you share a thought? thanks so much for any help.

do the following:
[[Wayfinder? &hereTpl=`navHere` (INCLUDE OTHER PARAMETERS THAT YOU LIKE)]]
In the navHere tpl write the following piece of code:
<li class="current" value="1">[[+wf.linktext]]</li>[[+wf.wrapper]]
I understand this would work out. Hope to get a response from you.

Related

Creating user editable chunk or snippet in ModX

I'm trying to create a chunk or a snippet a user can edit without touching the code. I thought it would be the best to include the content of a page since the pages use an editor. Can anyone tell me how I can accomplish this? Or tell me the best way to do it?
If I understand you correctly, you want to create, for example, a footer chunk with 3 editable regions.
I would do this by dedicating 3 resources for each editable region. Have the user make their changes via TinyMCE in these 3 resources (perhaps nest them in parent labled accordingly, eg: "Footer Columns"). Make sure they're hidden from menus so they don't come up by mistake.
Then use getResources within your chunk to display each. Eg:
<div class="footerchunk">
[[getResources?
&resources=`45,46,47`
&tpl=`footerColItem`
&depth=`0`
&limit=`3`
&includeContent=`1`
&showHidden=`0`
]]
</div>
Note that the resources in my example would correspond to the resources your using to allow the users to enter the text.
You would be required to build a footerColItem chunk, perhaps something like:
<div class="footercol">
[[+content]]
</div>
Note also the use of &showHidden=0
This is all from memory, so can't guarantee this will work straight away. Look at https://docs.modx.com/extras/revo/getresources for more info

Cannot identify the object in Selenium

I cannot identify the object of the icon showed in the attached screen shot. I have shown the HTML code as well.
The ID's are getting changed dynamically.
Can anyone guide on how to identity this kind of objects in Selenium?
If the ID is always changed, I recommend using CssSelector instead.
For instance,
<div id="running_number_12345" class="icon something">...</div>
You can use locator
driver.FindElement(By.CssSelector("div[class*='icon something']"));
If your icon doesn't have any specific css pattern, I recommend adding something in class attribute. If not, you have to use complex CssSelector to find it.
Try this
driver.findElement(By.cssSelector(".icon something"));

Selecting parent elements with WebdriverJS

I'm trying to create some scripts which require moving through a lot of on-the-fly HTML with random IDs. They require getting the parents of an element - but I'm not sure how to implement this in WebdriverJS.
If I access the element I want via a console, I can do the following to get it;
document.querySelector('span[email="noreply#example.com"]').parentNode.parentNode
Is there a way to do this in WDJS? I've looked and can't see anything obvious - it's specifically the parent stuff I'm having issue with. I saw that a possible solution may be xPath however I'm unsure of syntax having never used it before.
Thanks in advance!
I don't know the syntax of WebDriverJS. But the XPath is as below, you need a way to fit it in somewhere.
This is based on your CSS Selector, so please show HTML if needed.
.//span[#email='noreply#example.com']/../..
For example, if you have HTML like this
<div>
<div>
<span email="noreply#example.com">Contact me</span>
</div>
</div>
You can avoid using .. to go up.
.//div[./div/span[#email='noreply#example.com']]
If you have more levels to look up, another handy method would be using ancestor from XPath Axes.
Also, as #sircapsalot brought up, CSS selectors spec doesn't support parent selecting, so XPath is the only way to go, unless you inject JS.

How to apply images conditionally using entries and categories?

Using version 2.5.3 of ExpressionEngine, I have a list of products displayed by category, but I need the premium products among this list being featured with a small star image. How do you call conditionally this little stars besides the {title}?
At the moment this code shows stars for all products and that is not ideal.
<ol class="voices-list">
{exp:channel:entries channel="product" orderby="title" sort="asc" category="2&6" dynamic="no"}
<li>{title}<img class="feature_icon medium" src="{root_url}img/audio/smallstar.png" alt="star"></li>
{/exp:channel:entries}
</ol>
I need your help, please.
Best to set up a new checkbox field named "is_premium" with the value set to "y".
Next, edit each premium product entry and check the box and save.
Finally, in your template use this conditional.
{if is_premium == "y"}add star code{/if}
I like the approach shown in the answer posted by #MediaGirl and have used it many times.
An alternative approach is to handle it with a custom status rather than a custom field, if only to have the ability on the main edit screen to quickly and easily see and sort the list by "premium" (Zenbu could add the custom field to the edit screen, of course). The conditional would be similar, and of course the entries loop would need to have the status param of "open|premium".

Pagination on Single-Entry view in ExpressionEngine

I am building a website with ExpressionEngine as the CMS. There is a "Work" section that displays all the projects, and a detail view that shows each project individually. It is at this point, on the single-entry view that I would like to have "prev" and "next" pagination. In my tests I have made it work when the URL is "somedomain.com/index.php/work/detail/" but it does not work when the specific entry is part of the URL: "somedomain.com/index.php/work/detail/some_project/"
I've tried putting the pagination code outside of the {exp:weblog:entries} tag as well as within it, but to no avail. This is what my pagination code looks like:
{paginate}
<ul>
{if previous_page}
<li>< previous</li>
{/if}
{if next_page}
<li>next ></li>
{/if}
</ul>
{/paginate}
You are using pagination for lists of entries, what you need is the next / previous entry tags:
http://expressionengine.com/user_guide/modules/channel/entry_linking.html
Hmm. I'm not sure what the issue is here, as I've never used the {pagination} tag in that way. After checking out the docs, I see that the example code for prev/next links inside of the {pagination} tag is wrapped inside of an {exp:comment:entries} loop instead of the normal {exp:channel:entries} loop.
The docs aren't very clear about the scope of this particular feature of the {pagination} tag. You might want to double check that, in your {exp:channel:entries} loop, you haven't included pagination as a value in the disable parameter.
You could also check out the page in EE's user guide about Next/Prev Linking, which details the use of {exp:channel:next_entry} and {exp:channel:prev_entry} tags in place of the {pagination} tag that you've been using. I've used these tags without a hitch, so I definitely recommend trying them if you can't get your method to work.
Best of luck!

Resources