Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Couple of quick notes on fixing templates that used the {structure_entries} tag under EE2 when you've upgraded to EE3/EE4/EE5/+
- I've inerited a number of EE2 sites that we want to upgrade to EE5, they were built using {structure_entries} but that plugin
- hasn't been updated since EE2 and no-longer works with newer expression engine versions...
- 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.
- I found code like this in a template to build a sub-nav:
- ```
- {exp:structure_entries depth="1" parent="/{segment_1}/{segment_2}" }
- ...
- <a href="{page_uri}">
- {title}
- </a>
- ...
- {if "{channel} == "article"}{an_article_field_name}{/if}
- ...
- {/exp:structure_entries}
- ```
- And translated it into the following code that works under Structure itself:
- ```
- {exp:structure:nav_advanced start_from="/{segment_1}/{segment_2}" max_depth="1" parse="inward"}
- ...
- <a href="{root:page_url}">
- {root:title}
- </a>
- ...
- {if "{root:channel_short_name}" == "article"}{root:an_article_field_name}{/if}
- ...
- {/exp:structure:nav_advanced}
- ```
- (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