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

Plugin: Pages Menu

Development and Programming

Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

Hi all,

The Pages Menu Plugin returns a menu of pages created with the Pages module.

SIMPLE EXAMPLE:

{exp:pages_menu}
<a href="http://{url}">{title}</a>

{/exp:pages_menu}

OTHER EXAMPLE: (lists some of the available parameters and variables)



PARAMETERS: site_id (limit entries to one site) weblog_id (limit entries to one weblog) author_id (limit entries to one author) status (limit entries by status) default is ‘open’ order_by (any available field in exp_weblog_titles) default is entry_date sort (asc, desc) default is DESC limit (number of entries you want to show)

VARIABLES: {title} {url} {entry_id} {site_id} {weblog_id} {author_id} {url_title} {entry_id} {status} {count} {switch} {item_total}

download link

NOTE: It is possible to create a menu like this using the exp:weblog tag ( I discovered this myself after creating this plugin :lol: ) but the plugin is about 10 times faster! but the plugin might be a bit faster. ( happy Mr. Jones? 😉 )

WEBLOG TAG EXAMPLE:



						
       
Christopher Simmons's avatar
Christopher Simmons
68 posts
17 years ago
Christopher Simmons's avatar Christopher Simmons

Any chance we could add categories to this so that we can organize our links more effectively?

       
Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

Hi Chris,

Can you be a bit more specific? How do you want to use categories exactly, as parameters, or do you want to organise the results by category?

       
Christopher Simmons's avatar
Christopher Simmons
68 posts
17 years ago
Christopher Simmons's avatar Christopher Simmons

I’d like to organize the results by category, as in:

Category1 * link 1 * link 2 * link 3

Category2 * link 1 * link 2 * link 3

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Chris, you might place a feature request for the {page_…} variables to be made available to the Category Archive tag, as that is the typical output.

Incidentally, in my tests, this plugin was about 2-5 (not 10) times faster than the weblog entries tags, but the speed difference isn’t perceivable. You likely wouldn’t even know unless you were looking at the template parsing log and got your calculator out. 3-6 hundredths of a second or thereabouts is what I experienced. And of course, the Weblog entries tag has more robust implementation options, so the tradeoff is often entirely warranted. It’s also worth mentioning that if you use tag caching, the small speed difference is entirely nullified.

I’m not wanting to discourage people from working on or using Pages plugins, for the record, but I also don’t want users to get confused and think that a plugin is required for this rather basic functionality.

Edit: After a brief conversation with Cocoaholic, I see the difference in multiplier is staring and stopping our calculations at different points in the template parsing, but the measurement of actual time added to template rendering was the same.

       
zitro62's avatar
zitro62
9 posts
17 years ago
zitro62's avatar zitro62

Cocoaholic this is a great plugin!

Thanks for your work on this and for sharing it!

I’ll second the use of categories. Either way (parameters or results) I’m guessing I could then utilize this plugin to power a dynamically driven navigation with a drop down menu!

So when someone adds a static page to a particular category it automatically adds a navigation link in my drop down menu or it automatically adds to my side bar of other “relevant pages”.

Thanks again

       
Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

Thanks zitro62,

Since the same functionality can be achieved using EE tags I probably won’t develop this plugin any further. There is a feature request for adding the {page_…} variables to the Category Archive tag, I hope we’ll see that soon.

I have however updated the plugin to version 1.1

Changes: - the plugin now only shows current entries (not expired or in the fututre) - optimized the code (thanks for your suggestions Derek!)

download link

Cheers!

       
silenz's avatar
silenz
1,648 posts
17 years ago
silenz's avatar silenz
I’d like to organize the results by category, as in:

I made this somewhat deprecated plugin to create an expanding menu based on categories.

It was actually easy to transform it into a plugin that creates the same type of menu for pages created with the Pages Module. With the added benefit that it uses the pages-URIs instead of the category links. Once I have an 1.6 online to demonstrate it you may check it out.

       
Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

Sorry peeps, I can’t help it…

version 1.2 adds a {current_page} variable. It can be used in 2 ways, as a variable that returns “current” or conditional.

example:

<li {if url == current_page}class="current"{/if}><a href="http://{url}">{title}</a></li>

or just:

<li class="{current_page}"><a href="http://{url}">{title}</a></li>

which will output:

<li class="current"><a href="http://{url}">{title}</a></li>

download link

       
Christopher Simmons's avatar
Christopher Simmons
68 posts
17 years ago
Christopher Simmons's avatar Christopher Simmons

AAH!

I never noticed that your eyes move in your avatar.

That’s creepy.

       
Sam C's avatar
Sam C
16 posts
17 years ago
Sam C's avatar Sam C

Does the plugin parse the URLs and produce hierachal menu, or is it flat?

       
Eric Barstad's avatar
Eric Barstad
198 posts
17 years ago
Eric Barstad's avatar Eric Barstad

Looks like it’s flat…

Which is too bad. My PHP is too weak to even know how this would be done, but it would be great if the URIs could be parsed to determine nesting. For example, if you created the following page URIs:

/about/ /about/the_players/

the plugin could see that the second URI is the child of the first and output the nav accordingly.

       
Sam C's avatar
Sam C
16 posts
17 years ago
Sam C's avatar Sam C

Yep. I gave up and went with Tome. Hierarchal EE Pages as currently implemented are too difficult for a non-techy to deal with unfortunately.

       
Cocoaholic's avatar
Cocoaholic
445 posts
17 years ago
Cocoaholic's avatar Cocoaholic

It’s flat indeed.

I might look into making the menu hierarchal based on URI segments, but haven’t got much time these days. Who decided that people need sleep anyways? It’s such a waste of time…

Cheers!

       
Eric Barstad's avatar
Eric Barstad
198 posts
17 years ago
Eric Barstad's avatar Eric Barstad

Yeah, sleep is for wimps. Healthy, long-living, happy wimps.

       
1 2

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.