Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2013-07-04 21:38:12

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

Re: Mixed menu with section, category, articles

Els wrote:

if you contact Stef, no doubt he will send you a login.

Thanks Els, done.

Offline

#14 2013-07-05 06:02:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,101
Website GitHub Mastodon Twitter

Re: Mixed menu with section, category, articles

etc wrote:

I agree, but how do you get there? I thought the plugin author status gives you access to .org, but apparently it doesn’t.

I have no access to the .org site but you should ask Stef to send you password


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#15 2014-01-12 18:22:30

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

Re: Mixed menu with section, category, articles

is it possible to assign class for each link? and also for active current link another class.

Offline

#16 2014-01-12 18:43:18

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

Re: Mixed menu with section, category, articles

raminrahimi wrote #278090:

is it possible to assign class for each link? and also for active current link another class.

Yes, with etc_query (or jQuery client-side):

<txp:etc_query data='<txp:linklist />'
	replace='//a@@class=normal;//a[contains(@href, "<txp:page_url />")]@@class=active' />

Offline

#17 2014-01-12 20:11:37

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

Re: Mixed menu with section, category, articles

hi etc, thanks a lot :-) that’s work fine with <a> tag, but is it possible to assign the classes for li tag like this <li class=“name”>

Offline

#18 2014-01-12 21:45:03

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

Re: Mixed menu with section, category, articles

raminrahimi wrote #278092:

is it possible to assign the classes for li tag like this <li class=“name”>

Yes, provided you know its XPath from <a>. For example, if <a> are children of <li>, this will be

<txp:etc_query data='<txp:linklist wraptag="ul" break="li" />'
	replace='//li@@class=normal;//a[contains(@href, "<txp:page_url />")]/..@@class=active' />

You can even climb up the whole tree as done here by maniqui.

Offline

#19 2014-01-13 08:06:46

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

Re: Mixed menu with section, category, articles

now all my problems solved, but i can’t make sub-menus, could u plz help me?
thanks a lot.

Offline

#20 2014-01-13 12:15:09

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

Re: Mixed menu with section, category, articles

You can actually assign classes with core tags (to test), though constructing the current page url is tricky:

<txp:variable name="url"
	value='<txp:php>echo hu.substr(parse(''<txp:page_url type="req" />''), 1);</txp:php>' />

<txp:linklist wraptag="ul" break="">
	<li class="<txp:if_variable name='url' value='<txp:link_url />'>active<txp:else />normal</txp:if_variable>">
		<a href="<txp:link_url />"><txp:link_name /></a>
	</li>	
</txp:linklist>

This also will not do the ancestor thing.

raminrahimi wrote #278097:

now all my problems solved, but i can’t make sub-menus, could u plz help me?
thanks a lot.

What is the menu structure you want to obtain?

Offline

#21 2014-01-14 18:07:00

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 278

Re: Mixed menu with section, category, articles

now i can make my menus easily by the help of Links and <txp:linklist /> but there is no option to make sub-menus where i need, example my menu is:

<ul>
<li>home</li>
<li>about</li>
<li>services
<ul>
<li>service 1</li>
<li>service 2</li>
</ul>
</li>
</ul>

Offline

#22 2014-01-15 13:39:34

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

Re: Mixed menu with section, category, articles

You could create a link category menu, assign it to the links home and about. Next, create a link category services with parent menu, and assign it to service 1 and service 2 links. Then this should create your menu (untested):

<ul>
	<txp:linklist category="menu" wraptag="" break="li" />
	<txp:category_list type="link" parent="menu" exclude="menu" wraptag="li" break="">
		<txp:category title="1" link="1" />
		<txp:linklist category='<txp:category />' wraptag="ul" break="li" />
	</txp:category_list>
</ul>

Use some form within <txp:linklist /> if necessary. That’s not very clean (suggestions welcome), but should work.

Edit: added type="link".

Last edited by etc (2014-01-15 14:36:51)

Offline

#23 2014-01-22 18:26:59

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

Re: Mixed menu with section, category, articles

Here is how you can construct a multilevel links menu. Create menu link-type category with some subcategories (services and so on) and assign them to your menu links as needed. Create the following link-type menu form:

<txp:linklist category='<txp:category />' wraptag="" break="li" />
<txp:category_list type="link" parent='<txp:category />' exclude='<txp:category />' children="0" wraptag="" break="li">
	<txp:category title="1" />
	<ul><txp:php>echo parse(fetch_form('menu'));</txp:php></ul>
</txp:category_list>

Now call

<txp:category_list type="link" categories="menu" children="0" form="menu" wraptag="ul" break="" />

where appropriate, and you are done.

Edit: see it in action here.

Last edited by etc (2014-01-23 13:23:06)

Offline

Board footer

Powered by FluxBB