BoldMinded acquires Ansel, support ending for all add-ons. BoldMinded acquires Ansel, support ending for all add-ons. Read More →
Support has been discontinued. Issues remain available as an archive. Support has been discontinued. Issues remain available as an archive.
Has Children Conditional doesn't seem to be working
#15 opened by Brian Rivet
Description
I'm having a problem with a has_children conditional that seems to be evaluating to true even though the item in the menu hasn't got any children. Here's my code block:
{exp:construct:nodes tree_id="1"}
<li class="{construct:node_slug} {if construct:has_children}has-sub{/if}" role="none">
<a href="{construct:node_link}" data-level="{construct:node_level}" class="nav-{construct:node_slug} {if construct:node_external_link != ''}ext-link{/if}" {if construct:has_children}aria-haspopup="true" aria-expanded="false"{/if} {if construct:node_level == 1 } id="top-nav-{construct:node_slug}"{/if} {if construct:node_level == 1 AND construct:level_count == 1}tabindex="0"{if:else}tabindex="-1"{/if}>{construct:node_name}</a>
{if construct:has_children}
<ul role="menu" tabindex="-1" aria-label="{construct:node_name}">
{/if}
{construct:children}
</li>
{if construct:level_count == construct:level_total_results}
</ul>
{/if}
{/exp:construct:nodes}
I have a menu item in my menu that has no children but the aria-haspopup="true" aria-expanded="false" are still being output even though there are no children. Can you help me solve this?
Thanks,
Brian
Replies
- TJ Draper
Replied 4/17/2017 7:04 PM, Edited 5/19/2017 9:21 AM
I see there is more than one place that
construct:has_children
is being used. Does it seem to be working in those places? - Brian Rivet
Replied 4/17/2017 7:17 PM, Edited 5/19/2017 9:21 AM
Yes, it only seems to be in the first one where it is writing the aria attributes.
- TJ Draper
Replied 4/18/2017 11:54 AM, Edited 5/19/2017 9:21 AM
Well, frustratingly, I cannot reproduce the issue with the basic code example you posted. The only thing I did was clean it up a little and change indenting and line breaks to read through it and make sure there weren't any problems.
<ul> {exp:construct:nodes tree_id="1"} <li class="{construct:node_slug} {if construct:has_children}has-sub{/if}" role="none" > <a href="{construct:node_link}" data-level="{construct:node_level}" class="nav-{construct:node_slug}{if construct:node_external_link != ''} ext-link{/if}" {if construct:has_children}aria-haspopup="true" aria-expanded="false"{/if} {if construct:node_level == 1 } id="top-nav-{construct:node_slug}"{/if} {if construct:node_level == 1 AND construct:level_count == 1}tabindex="0"{if:else}tabindex="-1"{/if} > {construct:node_name} </a> {if construct:has_children} <ul role="menu" tabindex="-1" aria-label="{construct:node_name}"> {construct:children} {/if} </li> {if construct:level_count == construct:level_total_results} </ul> {/if} {/exp:construct:nodes}
- Brian Rivet
Replied 4/18/2017 6:51 PM, Edited 5/19/2017 9:21 AM
Would it help you to be able to log into my site to see the construct menu that I have set up? If so let me know where to send it and I can send credentials.
Thanks,
Brian
- TJ Draper
Replied 4/18/2017 8:25 PM, Edited 5/19/2017 9:21 AM
Hi Brian,
I’ve had the underpinnings for a private info field in place but never rolled out front end support for it. You should see a private info field now right below the comment field where you can add login credentials and such that only you and I will see.
Being able for me to log in is definitely the next step. I may also need to get (S)FTP access if possible if I can't figure anything out in the CP and templates. I may need to step through some code debugging (possibly). I assume this would be a staging environment?
- Brian Rivet
Replied 4/18/2017 8:34 PM, Edited 5/19/2017 9:21 AM
Hi TJ, yes it is a staging environment. I've put the credentials in the private field. Let me know if you need anything else.
- TJ Draper
Replied 4/19/2017 9:37 AM, Edited 5/19/2017 9:21 AM
When I log in to the FTP server with that user/pw, I don't see any files.
- TJ Draper
Replied 4/19/2017 9:50 AM, Edited 5/19/2017 9:21 AM
I’ve tried updating some templates and partials to do some testing, but I think template/partial files on the server are overriding? Because I’m not seeing any changes on the front end. Let me know if you can figure out why I can't see any files when logging in via FTP.
- Brian Rivet
Replied 4/24/2017 2:40 PM, Edited 5/19/2017 9:21 AM
Hi TJ. Sorry about that, there was something wrong in the account settings for the ftp account I gave you. It should be corrected now. If it drops you into an empty folder, try going up one level. Also, My client noticed some text that was showing up in the nav on all of the buttons: it said ASDF. I replaced the template with the one I had on file but then realized that that may have been something you had put in to test things. If that is the case, I am sorry. Please let me know if you still cannot access the files. The layout-header partial is the one with the code in it.
- TJ Draper
Replied 4/25/2017 10:09 AM, Edited 5/19/2017 9:21 AM
Hi Brian,
I should have looked at the source before instead of the inspector. It appears that JavaScript is adding the aria elements but if you look at the source rather than the live inspector, the markup is as it should be based on the conditional statements in the template.
Inspector:
Source: