1

Within Structure there is an option to "Hide From Nav". This works well and hides the choice from the nav tag. However, it also appears to hide it from the tag exp:structure:entries that is being used. Is there a way to keep entries from hiding the page?

I tried override_hidden_state="yes" however it no effect on the entries tag.

Help!

Brad

4
  • Can you share what you're trying to do exactly? Maybe there's another way to approach this problem. Jun 20, 2013 at 19:59
  • This is a site I inherited. It uses the nav tag to show things in the navigation, but then the structure entries loop to show the same content on the landing page. It uses this code: {exp:structure:entries channel="portfolio" parent_id="{structure:page:entry_id}" disable="categories|category_fields|member_fields|pagination"}
    – Parscale
    Jun 20, 2013 at 20:06
  • Oh yeah, duh. Structure Entries doesn't seem to handle the hidden_nav parameter just yet. I know there was an update that was supposed to but it just doesn't work and my support requests have gone unanswered. Have you tried using the channel:entries tag instead to loop through the Structure pages? Jun 20, 2013 at 20:09
  • I could, but I am not quite aware on how/where this parent id is related to the content. It appears this is a built-in relationship approach.
    – Parscale
    Jun 20, 2013 at 20:10

4 Answers 4

1

I believe you need one of the newer (beta) versions of SE. 1.3 or later. There is some info here on their support site and a link to a newer version of SE. I have a vague memory of using this on a project a few months ago.

https://getsatisfaction.com/twobelowzero/topics/hide_from_nav_variable

1

Brad, you're referencing Structure:Entries (http://buildwithstructure.com/tags#tag_entries) NOT structure_entries (http://devot-ee.com/add-ons/structure-entries) which some of the answers and comments are referring to.

Assuming it is the Structure native tag, then the documentation only states it supports the same variables as a channel tag - not that it supports the structure:nav parameters.

Your reference to the existing code:

{exp:structure:entries channel="portfolio" parent_id="{structure:page:entry_id}" disable="categories|category_fields|member_fields|pagination"}

Would mean that structure:entries tag would ignore channel and disable and they do nothing.

So the parameter isn't supported, possibly email Structure support to request they include in a future version?

Solution... (warning hack alert)

"hidden" (hidden from nav) is a column in the structure table (with a row for each page). The structure:entries tag takes the parameter parent_id and calls a function called get_child_entries passing the parent ID. This function does the SQL query and has it hard coded in to ignore any entry set to hidden.

2 solutions (the quick way):

modify lines 1115 - 1120 of sql.structure.php (v3.3.10)

$this->EE->db->select('entry_id')->from('structure')->where(array(
    'parent_id' => $parent_id,
    'entry_id !=' => 0,
    'hidden !=' => 'y',
    'site_id' => $this->site_id
))->order_by('lft', 'asc');

Change to:

$this->EE->db->select('entry_id')->from('structure')->where(array(
    'parent_id' => $parent_id,
    'entry_id !=' => 0,
    'site_id' => $this->site_id
))->order_by('lft', 'asc');

Removing the hidden reference in the WHERE clause. Downside this will change ALL calls to {exp:structure:entries}.

Alternative solution:

Add the parameter for override_hidden_state in the entries function (starts from line 111 in mod.structure.php) and pass it to get_child_entries as a second parameter. In get_child_entries (from line 1110 in sql.struture.php) add the extra parameter (giving it a default value of "n" to ensure all existing calls continue to work) an modify the SQL call to reflect the choice of showing hidden or not. I've not gone into the exact code examples as I expect the 1st solution would be suitable for most people and you've already solved the issue via custom SQL.

2
  • Well, that being said is "hidden from nav" changing a status or setting a custom flag for just Structure. If it is setting just a flag, then why is the entries not showing it?
    – Parscale
    Jun 22, 2013 at 20:31
  • Entries tag uses a different database query that has it hard coded. I've updated my answer to include fixes to solve it - I'll also contact the Structure team to make a change request. Jun 23, 2013 at 11:20
0

I just had to rewrite the whole thing with a custom query. Not the most fun I have ever had, but at least the relationships were very easy. It would be nice if this would work by default.

Brad

1
  • It appears from the link Kevin provided that structure:entries isn't going to be updated anytime soon so workarounds are the only fix currently unless you're one of the lucky few who have been able to get the proposed code edits to work. Jun 20, 2013 at 20:48
0

If you are using Structure:Entries plugin as Peter has mentioned above, you can simply create a category. I called mine "Include In Main Navigation". I included the category_id parameter in my tag pair: {exp:structure_entries category_id="1"}. Worked like a charm for me and didn't involve any hacking code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.