I am building a site in Expression Engine with a hard-coded navigation. I need to hide one of the nav items until the client makes an entry under a certain category, here's what I have right now:
{exp:channel:entries category_name="name" limit="1"}
{if count > 0}
<li> • Link</li>
{if:else}
(don't show anything)
{/if}
{/exp:channel:entries}
Any thoughts? Thanks!
yeah, exactly. If there is nothing there, it just won't show anything. If you needed to add a placeholder or something, you could use the {if no_results} tag.
Related
I'm making a custom multifield breadcrumb component with this code.
<ul class="breadcrumb-list">
<li class="breadcrumb-item" data-sly-repeat.textItem="${properties.text}">
<a class="breadcrumb-link" href="${properties.link['textItemList.index']}">${textItem}</a>
<p class="works">${properties.link[textItemList.index]}</p>
<p class="doesn't work">${properties.link['textItemList.index']}</p>
<span>//</span>
</li>
</ul>
I've added the paragraph elements to show how my properties display.
This is the html output:
If I remove the single quotes as in p class="works", the value displays the breadcrumb item's link value. If I add the single quotes as in p class="doesn't work", nothing displays.
You'd think that removing the quotes from the same value in the href would display my link as the href; however, when i remove the quotes in the href value, it removes the anchor tag altogether. when i add them back in, i can still see the anchor tag, but there is no href attribute at all, only the breadcrumb-link class.
How can I get the href value to show a link?
AEM evaluates al href before rendering the resulting html.
If the link is invalid it will not put anything under href
If the expression is invalid it will wipe out all the section
Have you tested with valid links?
This will not work only with plain text.
when i add them back in, i can still see the anchor tag, but there is no href attribute at all, only the breadcrumb-link class. - That is the expected behaviour. Because you have an array of links and putting the quotes will try to obtain an entry in the array by the 'textItemList.index' key, like you would do in a map, instead by the index. Nothing is found of course, so the anchor point is rendered without the href attribute.
when i remove the quotes in the href value, it removes the anchor tag altogether. - That is not the expected behaviour. Since you exemplify that inside the paragraph it works, then I suppose this is a display context issue. HTL should implicitly uses the uri context for href attribute values and text for content inside HTML elements according to the documentation.
Try explicitly mention the context like href="${properties.link[textItemList.index] # context = 'uri'}" or href="${properties.link[textItemList.index] # context = 'text'}", or check the contexts mentioned in the doc - unsafe should ultimately do the job.
None of this context worked for me, and Im facing the same issue, if I remove the single quote "'" it will display the href just ok, but since my href includes it none of the context mentioned above is doing the job.
Is there any solution for this out there?
I have got radio button like this:
<span><input onClick="if (EventHandlers.valueChanged(event, this)==false) return false;" class="radio"
label="Temp label" type="radio"
id="TempId_01" onblur="EventHandlers.onBlur(event)"
name="TempId"
value="01" delayOnChange="true" checked></input></span>
i want to get a value of checked item. I have tried smth like this (by xpath):
//input[#checked and #name="TempId"]/#value
However this not work at all, is it valid?
XPath queries need to return physical DOM elements that Selenium can work with. Selenium is then responsible for grabbing any attributes, details or properties from that element - your query is, by this point, all over and done with.
So, you'll need something like:
driver.findElement(By.xpath("//input[#checked and #name="TempId"]")).getAttribute("value");
I've got this code in my prestashop template, there is no loop, only conditional, and I get 5 back buttons (elseif section, first li tag), why is it happen?
{if $node.children|#count > 0 && ($smarty.get.controller!='product' && $smarty.get.controller!='category')}
<li class = "li-parent">
<asset class="menu-arrow-left"></asset>
<p><span>{$node.name|escape:'htmlall':'UTF-8'}</span></p>
{elseif $node.children|#count > 0 && ($smarty.get.controller=='product' || $smarty.get.controller=='category')}
<li class="li-back"><asset class="menu-arrow-right"></asset><p class="class="border-bottom-grandiet-small"><span>Back</span></p></li>
<li class = "li-parent">
<p><span>{$node.children[0].name|escape:'htmlall':'UTF-8'}</span></p>
{/if}
I don't see anything in this code that could cause displaying 5 back buttons. I suspect this code is included in some kind of loop and that's why it's displayed 5 times.
You should change the whole above code with:
testonly
and then look at page or page source and check how many testonly texts will appear.
It's also possible if you really use loop that you should use some extra condition. For example instead of:
<li class="li-back"><asset class="menu-arrow-right"></asset><p class="class="border-bottom-grandiet-small"><span>Back</span></p></li>
you should use
{if $node.children|#iteration eq 1}
<li class="li-back"><asset class="menu-arrow-right"></asset><p class="class="border-bottom-grandiet-small"><span>Back</span></p></li>
{/if}
and probably the rest should be more similar to the first condition so instead of:
<li class = "li-parent">
<p><span>{$node.children[0].name|escape:'htmlall':'UTF-8'}</span></p>
you should use:
<li class = "li-parent">
<p><span>{$node.name|escape:'htmlall':'UTF-8'}</span></p>
but it's really hard to say if we don't know what's the data structure and what exactly you want to achieve. If it still doesn't work you should provide more details to your question, explain what you want to achieve, what data you have in your variables and so on.
I have a problem with outputting categories in to a list.
It seems to create another ul(one for the channel:categories) within the my ul, and also creates empty lists before each list.
I used the exact same code for entries and it worked fine.
Is this a categories problem?
Here is the Code:
<ul>
<li><a {if segment_2 == ""} class="selected" {/if} href="">News & Events</a></li>
{exp:channel:categories
channel="news_events"
disable="pagination|member_data|trackbacks"
dynamic="no"}
<li>{category_name}</li>
{/exp:channel:categories}
<li><a {if segment_2 == "gallery"} class="selected"{/if} href="">Image Gallery</a></li>
Any help would be appreciated!
With regard to the code output, take a look at the style parameter for the channel categories tag: http://ellislab.com/expressionengine/user-guide/modules/channel/categories.html#channel-categories-style. You'll want to change it to style="linear" to use your own markup.
As for the blank output, it's going to be tough to diagnose without seeing your install but try getting rid of dynamic="no".
I'm a EE newbie. I have a template for subpage. all subpages use same subpage template. But for some sub pages I need to put an extra div (kinda info box), how can I put a condition? do I have to create a separate template only for a small div difference?
urls are consistent, so if i can make a url check and display div for right urls, it would work out for me, but can I put any php if {} condition into template?
Appreciate helps so much!!!
You can use ExpressionEngine conditionals.
See the documentation here:
http://expressionengine.com/legacy_docs/templates/globals/conditionals.html
Based on your description, I think you could do this based on the URL. You can read URLs using segment variables. So if your URL is http://www.foo.com/bar/test and you only want to show the box on the /bar/test page, use a conditional like this:
{if segment_2 == 'test'}
<div id="foobar">Lorem Ipsum</div>
{/if}