Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2015-02-28 18:59:43

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: How to make a menu

It seems to me that the initial question is not answered directly, until now. Or is that wrong?

I don’t know what freaant meant by “pages”. In the given example, “equipment” and “hardware” could be sections and “Drills, Screwdriver, Nails, Bolts” etc. articles. In such a case, the navigation would be formed from the sections with lists of articles.

Last edited by GugUser (2015-02-28 19:00:56)

Offline

#14 2015-03-01 17:49:10

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Re: How to make a menu

Well i am again confused.

I am using the Default Section that is auto-created for us on install.

Its the root index.php page or simply mysite.net/

I was trying to implement a menu with an active class
Like this:

<li<txp:if_section name="default"> class="current-menu-item"</txp:if_section>>
    <txp:section link="1" title="1" name="Home" />
  </li>  

But if i use name=“Home”“ it won’t work , it only works if i use name=“default”“

but then the url looks like this http://mysite.net/default/ not ideal nor wanted

but this works:

<li><a href="http://mysite.net" title="Fresh Sites">Home |</a></li>

I then created a page Home using the same Page and Form as what Default uses.

But then i end up with a URL of http://mysite.net/home/ and no content is output! even if there was output i don’t want /home/ in url

How do use default landing page with or without a title but have this url i.e. http://mysite.net/

PS on this page last example

<li<txp:if_section name=",article"> class="active"</txp:if_section>>
    <txp:section link="1" title="1" name="" />
  </li>

is it correct or is there a typo? why “,article” if i use that and leave name blank “ “ nothing happens


…. texted postive

Offline

#15 2015-03-02 03:20:18

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: How to make a menu

I never work with the default pages and forms. So I can’t aswer yor question in this sence.

But, I can show you how I made a simple and basic sections navigation.

Important: The section “home” must exist and “Section appears on front page?” for this section must be set to “Yes”.

Form “nav”:

<nav>
<ul>
<txp:if_status><li<txp:if_section name=","> class="current"><span><txp:section name="home" title="1" /></span><txp:else />><a href="/"><txp:section name="home" title="1" /></a></txp:if_section></li><txp:else /><li><a href="/"><txp:section name="home" title="1" /></a></li></txp:if_status>
<txp:section_list sections="section-1, section-2, etc" break="" form="nav-sections" />
</ul>
</nav>

Form “nav-sections”:

<li<txp:if_section name='<txp:section />'> class="current"><span><txp:section title="1" /></span><txp:else />><a href="/<txp:section />"><txp:section title="1" /></a></txp:if_section></li>

This is my solution, there are others, this is not the only way.

For a better understanding, you can break up the long lines.

Offline

#16 2015-03-03 00:23:51

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Re: How to make a menu

@GugUser thanks for the help. One question why do you use the span tag?
As far as the default page/form i should be more careful when starting a new site. in this case i am updating my first TxP site to be more robust. My first effort was pretty basic and I unwitting used the default page. i do try to create a home one and use that.
again thanks


…. texted postive

Offline

#17 2015-03-03 03:17:18

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: How to make a menu

bici wrote #288691:

One question why do you use the span tag?

In some cases the spans are useful for the CSS. If you don’t need them, you can remove them. No problem.

Offline

#18 2015-03-10 04:26:35

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Re: How to make a menu

I am trying to create a menu with sections and categories using the TXPTIP article

I have the following forms:

NAV – misc form

<txp:section_list form="navbuild" class="" break=""
wraptag="" sections="default,about,archive,galleries,contact" /> 

NAVBUILD – article form

<txp:if_different>
<li<txp:if_section name='<txp:section />'>
<txp:if_individual_article><txp:else />class="current-menu-item"</txp:if_individual_article></txp:if_section>>
<txp:section link="1" title="1" /></li>
</txp:if_different>
<txp:if_section name='<txp:section />'>
<txp:article_custom section='<txp:section />' form="navbuildlinks2"  />
</txp:if_section>

NAVBUILDKINKS2 – article form

<li class="current-menu-item"<txp:if_article_id> class="sub-menu"</txp:if_article_id>> <a href="<txp:permlink />"><txp:title /></a></li>

it’s more less working fine. Except that I don’t want sub-menus to appear for About and Contact Sections as they simply have only one entry each.

clicking on About causes the entry title to also appear as … “ About “ > “What Are We About” , when Section is not active only the “About” is visible.

For galleries it works like I wanted with subcategories appearing once we are on the Galleries sections/categories.
I tried limiting by section IDs but not with any success.

Is there a way to ONLY show the subcategories for the section Galleries??


…. texted postive

Offline

#19 2015-03-13 06:48:15

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Re: How to make a menu

UPDATE:
I solved this issue via brute force.

I hand code navigation this way:

<li id="menu-item" class="menu-item"><a href="http://mysite.net" id="navHome" title="Fresh Rides" accesskey="h">Home |</a></li>
<li<txp:if_section name="about"> class="current-menu-item"</txp:if_section>> 
    <txp:section link="1" title="1" name="About" />  
  </li>
 <li<txp:if_section name="archive"> class="current-menu-item"</txp:if_section>>
    <txp:section link="1" title="1" name="Archive" />  
  </li>
<li<txp:if_section name="galleries">  class="current-menu-item"</txp:if_section>>
    <txp:section link="1" title="1" name="Galleries" />
  </li>
<li id="menu-item" class="menu-item"><a href="http://mysite.net/contact" id="abut" title="Contact Me"> Make Contact</a></li> 

then when one lands on the galleries section where i want to show Galleries and its categories I have this code:
which is called by a form misc nav

<li id="menu-item" class="menu-item"><a href="http://mysite.net" id="navHome" title="Fresh Rides" accesskey="h">Home |</a></li>
<li<txp:if_section name="about"> class="current-menu-item"</txp:if_section>> 
    <txp:section link="1" title="1" name="About" />  
  </li>
 <li<txp:if_section name="archive"> class="current-menu-item"</txp:if_section>>
    <txp:section link="1" title="1" name="Archive" />  
  </li>
<!-- woot! -->
<li<txp:if_section name="galleries">  class="current-menu-item"</txp:if_section>>
    <txp:section link="1" title="1" name="Galleries" />
<txp:article_custom section='<txp:section />' form="navbuildlinks2G"  />
  </li>
<!-- //end -->
<li id="menu-item" class="menu-item"><a href="http://mysite.net/contact" id="cbut" title="Contact Me"> Make Contact</a></li> 

navabuildlinks2 has this ;

<!-- works  -->
   <li class="current-menu-item"<txp:if_article_id> class="sub-menu"</txp:if_article_id>><a href="<txp:permlink />"><txp:title /></a></li> 

it’s not as automagic as i had wanted but good enough for me.

After ten years i’ll be updating to new version of my in a week or so.


…. texted postive

Offline

Board footer

Powered by FluxBB