Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. ## Couple of quick notes on fixing templates that used the {structure_entries} tag under EE2 when you've upgraded to EE3/EE4/EE5/+
  2. I've inerited a number of EE2 sites that we want to upgrade to EE5, they were built using {structure_entries} but that plugin
  3. hasn't been updated since EE2 and no-longer works with newer expression engine versions...
  4.  
  5. So, generally structure_entries is used for building a sub-nav, listing page links from a branch of the nav tree. I assume this functionality didn't originally exist in Structure, hence someone created structure_entries, but (for my use-case at least) you can achieve the same functionality in Structure itself these days with a pretty simple code translation, meaning you can ditch {structure_entries} completely.
  6.  
  7. I found code like this in a template to build a sub-nav:
  8. ```
  9. {exp:structure_entries depth="1" parent="/{segment_1}/{segment_2}" }
  10. ...
  11. <a href="{page_uri}">
  12. {title}
  13. </a>
  14. ...
  15. {if "{channel} == "article"}{an_article_field_name}{/if}
  16. ...
  17. {/exp:structure_entries}
  18. ```
  19. And translated it into the following code that works under Structure itself:
  20. ```
  21. {exp:structure:nav_advanced start_from="/{segment_1}/{segment_2}" max_depth="1" parse="inward"}
  22. ...
  23. <a href="{root:page_url}">
  24. {root:title}
  25. </a>
  26. ...
  27. {if "{root:channel_short_name}" == "article"}{root:an_article_field_name}{/if}
  28. ...
  29. {/exp:structure:nav_advanced}
  30. ```
  31. (Root in this instance starts from the tree branch you're initially starting from, not the Root of the structure tree (if your subnav was multi-level then for the child items you'd use child: instead of root: etc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement