We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

New Module: Structure - Uses entries to create a page hierarchy for static and listing pages

Development and Programming

sambo's avatar
sambo
80 posts
16 years ago
sambo's avatar sambo

I just did a hack to make it work for my current client:

I added this function to the extension:

function fixAccents($text) {
   global $export;
   $search  = array ('á', 'é', 'ý', 'ú', 'í', 'ó', 'þ',  'æ',  'ö', 'ð');
   $replace = array ('a', 'e', 'y', 'u', 'i', 'o', 'th', 'ae', 'o', 'd');
   $export    = str_replace($search, $replace, $text);
   return $export;
}

And then added this line:

$entry_title = $this->fixAccents(strtolower($entry_title));

…just before this one:

$url_title = strtolower($REGX->create_url_title($entry_title));

This is obviously not the prefered solution because if I would update Structure - and hence remove my hack - then all URLs might be rebuilt incorrectly again.

Best, Sammi

       
viewcreative's avatar
viewcreative
116 posts
16 years ago
viewcreative's avatar viewcreative

Hi,

First things first, thanks for a great module/extension patches up a huge gap in EE default functionality. However, either I’ve discovered a bug (or limitation) or I’m missing something very obvious.

Imagine the following tree structure

* Home
    * About Us
          o Rural developement plan 2007-2013
          o Rural Partnership
                + Members
                + Meetings
                + Terms of Reference
                + Members Area
          o Rural development team
          o Local action group
                + Members
                + Meetings
                + Terms of Reference
                + Members Area
          o Publications
                + Local Strategies
                + National Stratergies
                + Sub-regional Stratergies
                + European Stratergies
    * Latest Developments
          o Community
          o Rural Enterprise
          o Arts & Heritage
          o Tourism
          o Environment
          o Project ideas
    * What's On
    * News
    * Links

Using {exp:structure:nav_main} to output the main nav:

<ul id="nav">
  <li class="nav-home here"><a href="/">Home</a></li>
  <li class="nav-about"><a href="/about/">About Us</a></li>
  <li class="nav-latest-developments"><a href="/latest-developments/">Latest Developments</a></li>
  <li class="nav-whats-on"><a href="/whats-on/">What's On</a></li>
  <li class="nav-news"><a href="/news/">News</a></li>
  <li class="nav-links last"><a href="/links/">Links</a></li>
</ul>

…and {exp:structure:nav_sub} to output the sub nav. However, this is where I begin to get confused.

If you issue {exp:structure:nav_sub} with out any parameters, according to the documentation it should display the entire branch (show children, perhaps I’m interpreting this wrong):

Show Depth {exp:structure:nav_sub show_depth="2"}, no limit by default Always show children pages up to a specified depth. Designed to work with the start_from parameter.

However, it only ever shows the top level.

If you issue the tag with a show depth i.e. {exp:structure:nav_sub show_depth="2"} then it works for nodes that have children, however (this is where I think I’ve found a bug), nodes without children, instead of displaying nothing as you would expect seem to do something very different (and strange!) instead.

E.g. when navigating to a page without sub-pages, i.e. home, links etc you get the following tree:

<ul id="nav-sub">
<li class="sub-level-0"><a href="/about/rural-developement-plan-2007-2013/">Rural developement plan 2007-2013</a></li>
<li class="sub-level-0"><a href="/about/rural-partnership/">Rural Partnership</a>
<ul>
<li class="sub-level-1"><a href="/about/rural-partnership/members/">Members</a></li>
<li class="sub-level-1"><a href="/about/rural-partnership/meetings/">Meetings</a></li>
<li class="sub-level-1"><a href="/about/rural-partnership/terms-of-reference/">Terms of Reference</a></li>
<li class="sub-level-1 last"><a href="/about/rural-partnership/members-area/">Members Area</a></li>
</ul>
</li>

<li class="sub-level-0"><a href="/about/rural-development-team/">Rural development team</a></li>
<li class="sub-level-0"><a href="/about/local-action-group/">Local action group</a>
<ul>
<li class="sub-level-1"><a href="/about/local-action-group/members/">Members</a></li>
<li class="sub-level-1"><a href="/about/local-action-group/meetings/">Meetings</a></li>
<li class="sub-level-1"><a href="/about/local-action-group/terms-of-reference/">Terms of Reference</a></li>
<li class="sub-level-1 last"><a href="/about/local-action-group/members-area/">Members Area</a></li>
</ul>
</li>
<li class="sub-level-0"><a href="/about/publications/">Publications</a>

<ul>
<li class="sub-level-1"><a href="/about/publications/local-strategies/">Local Strategies</a></li>
<li class="sub-level-1"><a href="/about/publications/national-stratergies/">National Stratergies</a></li>
<li class="sub-level-1"><a href="/about/publications/sub-regional-stratergies/">Sub-regional Stratergies</a></li>
<li class="sub-level-1 last"><a href="/about/publications/european-stratergies/">European Stratergies</a></li>
</ul>
</li>
<li class="sub-level-0"><a href="/latest-developments/community/">Community</a></li>
<li class="sub-level-0"><a href="/latest-developments/rural-enterprise/">Rural Enterprise</a></li>
<li class="sub-level-0"><a href="/latest-developments/arts-heritage/">Arts & Heritage</a></li>

<li class="sub-level-0"><a href="/latest-developments/tourism/">Tourism</a></li>
<li class="sub-level-0"><a href="/latest-developments/environment/">Environment</a></li>
<li class="sub-level-0 last"><a href="/latest-developments/project-ideas/">Project ideas</a></li>
</ul>

Which just doesn’t make any sense at all! (The nodes in question don’t have sub-pages, it should return nothing)

Can anyone offer any insight? Is this a bug or have I completely mis-understood the documention?

Thanks in advance.

       
philfreo's avatar
philfreo
50 posts
16 years ago
philfreo's avatar philfreo
I love Structure, but occasionally run into a problem such as this one. I’m trying to make the URL in Structure to be “news” instead of “news-1”. I have the weblogs: Pages, News I created an entry in Pages with a title and url_title of “news”. See screenshot for settings. Every time I rename from “news-1” to “news” it changes it back. Obviously it seems like Structure thinks there is already a name of this type, but I don’t think there is and I can’t find one. Where should I be looking specifically? I’ve looked around and even done searches, but the only thing that comes up is the same News page that has news-1 in the Structure URL. Is it possible Structure shouldn’t be renaming it? EE 1.6.8, Structure 1.3.0

Anyone have any ideas about this? I’ve looked in MySQL but the only thing I found resembling “news” was the url_title for the correct weblog entry. Why is it getting renamed to news-1 for the Structure URL?

       
Brian M.'s avatar
Brian M.
529 posts
16 years ago
Brian M.'s avatar Brian M.

I’ve just seen something like this. I just went back to a client’s site to do a bit of work, and there’s a few entries that are now named things like “vermont-1-1-1-1-1-1”.

Do you have revisions turned on?

       
philfreo's avatar
philfreo
50 posts
16 years ago
philfreo's avatar philfreo
I’ve just seen something like this. I just went back to a client’s site to do a bit of work, and there’s a few entries that are now named things like “vermont-1-1-1-1-1-1”. Do you have revisions turned on?

Good idea - but I don’t have versioning turned on for either (Pages or News) weblog. The problem is with Structure’s “Page URL”, not with the entries’ “URL Title”. Where is this field stored / calculated?

       
Brian M.'s avatar
Brian M.
529 posts
16 years ago
Brian M.'s avatar Brian M.

I don’t know unfortunately - but I’m seeing -1-1-1-1 in Structure’s Page URL, the entry’s URL title is fine…

       
Jack McDade's avatar
Jack McDade
425 posts
16 years ago
Jack McDade's avatar Jack McDade
I don’t know unfortunately - but I’m seeing -1-1-1-1 in Structure’s Page URL, the entry’s URL title is fine…

try deleting the Structure URL slug and saving it blank.

       
philfreo's avatar
philfreo
50 posts
16 years ago
philfreo's avatar philfreo
I don’t know unfortunately - but I’m seeing -1-1-1-1 in Structure’s Page URL, the entry’s URL title is fine…
try deleting the Structure URL slug and saving it blank.

I just tried this and when I went back into it it put “news-1” back in. I can rename it to something else like “testing123” with no problem but then trying to rename it to “news” still reverts back to “news-1”.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

There probably is a “news” url_title already. EE just makes sure they are unique.

       
philfreo's avatar
philfreo
50 posts
16 years ago
philfreo's avatar philfreo
There probably is a “news” url_title already. EE just makes sure they are unique.

No… the only “news” url_title is the url_title of the weblog entry I’m currently trying to fix. The problem isn’t with url_title, it’s with the separate field Structure uses called “Page URL”.
See my screenshot here: http://ellislab.com/forums/viewthread/91290/P738/#617275

       
stinhambo's avatar
stinhambo
1,268 posts
16 years ago
stinhambo's avatar stinhambo

Has the issue with posting an SAEF entry to a listing been resolved yet? It seems silly to make the weblog an Asset when it isn’t one.

Assets to me are indiscriminate pieces of information that can be posted to a template.

       
illustrationdan's avatar
illustrationdan
26 posts
16 years ago
illustrationdan's avatar illustrationdan

@philfreo

I was having the same issue and it seems to be an issue with creating a template group and having a structure uri the same name.

So traditionally having a news template group would render as www.yoursite.com/index.php/news/post With structure its basically doing the same thing so thats why youre getting www.yoursite.com/index.php/news-1/. Now, logically deleting that template group should have did the trick but it then would generate a Duplicate URI error when i would try and add a new post with the same template group uri and if i didnt get the duplicate uri error it would just add the -1.

I really dont know what the reason is but the only fix is to un-install both the module and extension and re-intall them, that and dont have any template groups with the same name as a structure post.

Hope that helps

       
viewcreative's avatar
viewcreative
116 posts
16 years ago
viewcreative's avatar viewcreative

Can anyone confirm whether this is a bug or not:

http://ellislab.com/forums/viewreply/618677/

It’s really important that I find out fairly rapidly as it will ultimately determine how I get around it. Apologies for the bump but in a thread of this scale I’m worried my post will dissapear un-noticed.

Again, it really is just confirmation that this is a bug and not something silly I’m doing, thanks in advance.

M

       
viewcreative's avatar
viewcreative
116 posts
16 years ago
viewcreative's avatar viewcreative

Ok. I’m fairly (99%) certain this is indeed a bug.

I’ve had a dig around the module and it seems to be an issue with top level nodes and this block of code:

Line ~568

if($node['isLeaf']) {
  $leaf_node = $current_node;
  $node = $this->nset->getNode($node['parent_id']);
  $current_node = $this->nset->getNode($current_node['parent_id']);
}

The issue being that if your top level is indeed ‘isLeaf’ then the node array is replaced with the return value of $this->nset->getNode($node[‘parent_id’]) which is not what we want.

Adding a simple conditional to check that $node[‘isLeaf’] && $node[‘parent_id’] != 0 like so:

if($node['isLeaf'] && $node['parent_id'] != 0) {
  $leaf_node = $current_node;
  $node = $this->nset->getNode($node['parent_id']);
  $current_node = $this->nset->getNode($current_node['parent_id']);
}

Seems to do the trick. Hope this helps someone else out as it has had me pulling my hair out for a couple of days.

Regards

       
Jack McDade's avatar
Jack McDade
425 posts
16 years ago
Jack McDade's avatar Jack McDade

thanks viewcreative for looking into this – i’m going to dig in and make sure that it is, in fact a bug, or if it’s just oversight in not accommodating a specific number of levels or something to that effect. Can you tell me your situation or setup so i could recreate it?

       
First 51 52 53 54 55 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.