Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#277 2015-04-16 06:12:21

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

detail wrote #290016:

I have been using your fabbo plugin and it has worked a treat.

Nice to hear!

So, in the sub-section B3 menu I want to be able to pull out a few existing articles that are actually from another section.

Reckon this is in any way possible? Somehow I was thinking categories might be useful in this instance.

I think this is a deficiency that @wavesource was alluding to a little while ago. Currently it’s possible to add a menu item that’ll give you a link to a category page but no articles belonging to that category are listed in the actual menu.

I’ll look into it – but please give a couple of weeks, I’ve got the outlaws visiting at the moment …!

Offline

#278 2015-04-16 06:32:28

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 176
Website

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

Currently it’s possible to add a menu item that’ll give you a link to a category page but no articles belonging to that category are listed in the actual menu.

Yeah, I have the sub-section in the menu but no way to link the articles.

Essentially it is a “Best Of” type situation where I want to pick up quite a few articles from completely different sub-sections and have them listed in their own sub-section menu.

No stress about the timing here, I’m my own client on this one, plenty of other bits to keep me occupied.

Just totally enjoy the company of your in laws, and any recovery period that may be needed.

g

Offline

#279 2015-04-16 09:43:44

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

It’s easy to inject articles (and other stuff) inside the menu. Suppose that your B3 (empty) section is called featured, assign the featured articles some category (say, featured) and test this:

<txp:variable name="featured"><txp:article_custom wraptag="ul" break="li" category="featured" sort="title">
	<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom></txp:variable>

<txp:etc_query data='<txp:adi_menu menu_id="" class="menu" active_class="current" current_children_only="1" parent_class="" articles="1" active_articles_only="1" article_attr=''sort="title" status="live" '' sort="adi_menu_sort" article_position="before" />'
	replace='//a[@href="<txp:section name="featured" url="1" />"]$={?featured}' />

Offline

#280 2015-04-16 20:59:06

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 176
Website

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

Humm, that will be an elegant solution. Thanks for helping out, I haven’t used etc_query before. It can do amazing things.

Sadly at the moment it isn’t quite working. Nothing in the menu shows up when I modify your code with my category and section names.

<txp:variable name="te-araroa"><txp:article_custom wraptag="ul" break="li" category="te-araroa" sort="title">
	<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom></txp:variable>

<txp:etc_query data='<txp:adi_menu menu_id=" " class="menu" active_class="current" current_children_only="1" parent_class=" " articles="1" active_articles_only="1" article_attr= ' 'sort="title" status="live" ' ' sort="adi_menu_sort" article_position="before" />'
	replace='//a[@href="<txp:section name="huts-campsites-te-araroa" url="1" />"]$={?te-araroa}' />

I’ve done a few variations, taking out bits just to get something happening but ain’t any better.

Do you think it’s choking on this bit?

article_attr= ' 'sort="title" status="live" '

There’s a remarkable lot of ‘ and “ competing for attention.

Yes, I did install etc_query, and I can’t see any curly quote marks which is my usual issue . . .

cheers

g

Offline

#281 2015-04-17 07:30:16

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

detail wrote #290042:

Do you think it’s choking on this bit?

article_attr= ' 'sort="title" status="live" '...

There’s a remarkable lot of ‘ and “ competing for attention.

Some text editors prettify beyond all recognition. :) There shouldn’t be a space before neither between two single quotes. To make it easier, you can store the menu in a variable and pass it to etc_query like this:

<txp:variable name="te-araroa"><txp:article_custom wraptag="ul" break="li" category="te-araroa" sort="title">
	<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom></txp:variable>

<txp:variable name="menu">
<txp:adi_menu menu_id=" " class="menu" active_class="current" current_children_only="1" parent_class=" " articles="1" active_articles_only="1" article_attr= 'sort="title" status="live" ' sort="adi_menu_sort" article_position="before" />
</txp:variable>

<txp:etc_query data={?menu}
	replace='//a[@href="<txp:section name="huts-campsites-te-araroa" url="1" />"]$={?te-araroa}' />

Pass debug="d" attribute to etc_query to see if the menu is well imported. If this does not help, check that

  • txp is 4.0.7 or above
  • php is 5.3.10 or above

Offline

#282 2015-04-17 08:17:28

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 176
Website

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

Sadly still an issue, the menu is not visible.

The basic menu is loading according to your debugger but without the etc_query changes.

So I checked the php and my host said 5.2, so I have changed it to 5.3. They don’t tell me what version of 5.3 it is.

There’s a 20 minute delay for the switchover apparently, and it’s 8pm on Friday night so I’m wondering what I’m doing still sitting at my computer interface.

In any case it’s porn o’clock so the whole internet has slowed down, too many people online, might as well take a break until tomorrow.

Thanks muchly for your help, it seems it might not be just my poor understanding of the coding after all.

Offline

#283 2015-04-17 08:21:06

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 176
Website

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

Yahoo!!!

No, it is looking just fine, well almost, but that is something that is in my hands.

Leave it to tomorrow.

Thanks again, just brilliant.

Offline

#284 2015-04-19 00:14:37

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 176
Website

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

Making some progress here.

The following code is working, producing the article list for the category “te-araroa” that I want, but it has a couple of issues.

<nav role="navigation">

  <txp:variable name="te-araroa">
    <txp:article_custom wraptag="ul" break="li" class="menu_article" category="te-araroa" limit="100" sort="title">
      <txp:permlink><txp:title /></txp:permlink>
    </txp:article_custom>
  </txp:variable>

  <txp:variable name="menu1">
    <txp:adi_menu menu_id="" class="menu" active_class="current" current_children_only="1" parent_class="" articles="1" active_articles_only="1" article_attr='sort="title" status="live" class="menu_article"' sort="adi_menu_sort" article_position="before" />
  </txp:variable>

  <txp:etc_query data={?menu1}
    replace='//a[@href="<txp:section name="huts-campsites-te-araroa" url="1" />"]$={?te-araroa}' />

</nav>

1. I have created a few articles that are in the huts-campsites-te-araroa sub-section. These appear twice when the te-araroa menu is active: initially folded into the category te-araroa articles, then repeated as specific subsection articles.

2. The specific te-araroa articles are always shown. This does not happen if I’m using the pre-category fiddling adi_menu code, which is basically identical.

<txp:adi_menu menu_id=" " class="menu" active_class="current" current_children_only="1" parent_class=" " articles="1" active_articles_only="1" article_attr='sort="title" status="live" class="menu_article"' sort="adi_menu_sort" article_position="before" />

So the code at the top not only shows the specific te-araroa articles twice, they are always shown when other sub-sections are active.

Man, I am so close. I can get around some of this using if_section but I would prefer to make it more bullet proof than that.

Last edited by detail (2015-04-19 00:15:12)

Offline

#285 2015-05-05 08:19:26

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 176
Website

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

Sorry, this isn’t quite resolved, as yet.

I’ve got around the category items always being shown in all of the section menus with a conditional if_section.

<nav role="navigation">

<txp:if_section name="huts-campsites-te-araroa">

  <txp:variable name="te-araroa">
    <txp:article_custom wraptag="ul" break="li" class="menu_article" category="te-araroa" limit="100" sort="title">
      <txp:permlink><txp:title /></txp:permlink>
    </txp:article_custom>
  </txp:variable>

  <txp:variable name="menu1">
    <txp:adi_menu menu_id="" class="menu" active_class="current" current_children_only="1" parent_class="" articles="1" active_articles_only="1" article_attr='sort="title" status="live" class="menu_article"' sort="adi_menu_sort" article_position="before" />
  </txp:variable>

  <txp:etc_query data={?menu1}
    replace='//a[@href="<txp:section name="huts-campsites-te-araroa" url="1" />"]$={?te-araroa}' />

  <txp:else />

  <txp:adi_menu menu_id="" class="menu" active_class="current" current_children_only="1" parent_class="" articles="1" active_articles_only="1" article_attr='sort="title" status="live" class="menu_article"' sort="adi_menu_sort" article_position="before" />    

</txp:if_section>
</nav>

That means I don’t have the category list in the menu all the time, just when in the right sub-section. That’s good.

I still have this issue: When I’m in the sub-section “huts-campsites-te-araroa”, the category list from a number of different sections, that’s the “best of” articles, 68 of them in total, are shown are in the menu in perfect order. Fantastic.

The problem is that there are 30 of these 68 articles which have been specifically assigned to this sub-section, and are in a separate list that is at the end of the category list so they are effectively listed twice, the menu shows 68 + 30, instead of just the 68.

Is there some way that I can stop these articles from showing up in the menu?

Confused?

The article list page is here

The menu is on the right hand side. I still have a bit of tweeeeking with the colour scheme here to get the menu to read effectively but you should be able to see that some articles are being listed twice.

Last edited by detail (2015-05-05 08:23:14)

Offline

#286 2015-05-05 08:48:02

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

Sorry, I was away from the forum for a while. Just to be sure: you want to insert into “huts-campsites-te-araroa” section listing the articles with “te-araroa” category, without repetitions and in the alphabetical order (the last is the hardest part)? If we drop the alpha order for the moment, this should work (untested):

<nav role="navigation">

<txp:variable name="menu1">
  <txp:adi_menu menu_id="" class="menu" active_class="current" current_children_only="1" parent_class="" articles="1" active_articles_only="1" article_attr='sort="title" status="live" class="menu_article"' sort="adi_menu_sort" article_position="before" />
</txp:variable>

<txp:if_section name="huts-campsites-te-araroa">

  <txp:etc_query name="te-araroa" markup="db" populate="article" wraptag="ul" break="li" class="menu_article" limit="100"
    data="(Category1='te-araroa' OR Category2='te-araroa') AND Section !='huts-campsites-te-araroa' ORDER BY Title">
      <txp:permlink><txp:title /></txp:permlink>
  </txp:etc_query>

  <txp:etc_query data="{?menu1}"
    replace='//a[@href="<txp:section name="huts-campsites-te-araroa" url="1" />"]$={?te-araroa}' />

  <txp:else />

  <txp:variable name="menu1" />

</txp:if_section>
</nav>

Be sure to (re)download the latest etc_query version. If it works, we will see for the order.

Edit: or even this:

  ...
  <txp:etc_query name="te-araroa" markup="db" populate="article" wraptag="ul" break="li" class="menu_article" limit="100"
    data="(Category1='te-araroa' OR Category2='te-araroa' OR Section='huts-campsites-te-araroa') ORDER BY Title">
      <txp:permlink><txp:title /></txp:permlink>
  </txp:etc_query>

  <txp:etc_query data="{?menu1}"
    replace='//a[@href="<txp:section name="huts-campsites-te-araroa" url="1" />"]={?te-araroa}' />
  ...

Last edited by etc (2015-05-05 14:39:14)

Offline

#287 2015-05-05 08:54:41

detail
Member
From: geez, I seem to be in NZ
Registered: 2010-07-13
Posts: 176
Website

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

Wow, that was speedy.

9pm here in New Zealand, we like to get our days over early, so I might leave this brain teaser until morning.

Thanks again.

Offline

#288 2015-10-23 16:05:24

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: adi_menu – section hierarchy, section menu and breadcrumb trail

Hi Adi,

I’d like to suggest a little modification at the end of adi_menu_lineage when $linkclass is empty :

$out[] = tag($crumb,'a',' ' .($linkclass ? 'class="'.$linkclass.'"' : ''). ' href="'.$section_list[$child]['url'].'"') :

Offline

Board footer

Powered by FluxBB