Hi! I’ve been a fan of CodeIgniter and done some work in it and I like it a lot. Now I need a CMS for a clients website and I feel EE is the most natural choice. But I’m fumbling a bit and need your help please 😊
So you know: I’ve created a module with a CP settings page (form) and a plugin (that spits out random crap) just to get started with EE and see how it all works. I like it!
What do I want? I want to create a typical left hand menu that simply shows all pages there are, in a tree structure.
I’ve create a channel that I’ve named “Pages” (not the Pages module tab). I’ve created a Category-group that I’ve assigned to the Pages channel. When creating a new entry with the channel type Pages, I also assign it to a category belonging to the Pages channel.
I want the URL:s to be like: www.mysite.com/product_info/magic_cube Where “product_info” is the category and “magic_cube” is an entry.
The Pages module requires me to so manually. It works great. But I want this done automatically, based on the assigned Category.
Hope someone understand me and can help out. Thanks!
To make it easier for you to help, here’s an examplesite using EE: http://home.buffalo.com/events/venue/penn-dixie-paleontological-and-outdoor-education-center/
I like their menus and SEO friendly URL:s. Have they really done it all by having templates as folders? And when they have as many as 3 or more depths of folders, it really is templates?
Would love to see the admin background of such a site and the templates.
Hi swedie,
The URL structure is probably the most important thing to understand in EE. Basically (without getting into add-ons that’ll confuse you) theres two options
1) You set up template groups and templates. If you have a template called ‘upcoming’ in the ‘events’ template group, then this template will display if you go to the url yoursite.com/events/upcoming
Read up on the channel:entries tag. You can have a single tag, that will automatically know whether to display a single post, all the posts or only posts in a certain category. So if the url was events/upcoming/category/races - this would use the events/upcoming template, and feed the category ‘races’ into your channel entries tag automatically. Likewise, if the url was events/upcoming/saturday_night_disco, it would again use the events/upcoming template, and look for an entry with a url title of saturday_night_disco. Make sense?
2) You use the built-in pages module. This means you can type in your own url for each entry (as many levels as you want) and tell it which template to use. So you can have 100 pages, all different urls, using one template.
Let me know if you have any other questions 😊
Thanks. I do know of the {ext:channel:entries} function, and I’ve done some tries with it. But not quite figured out how to make use of it, my way.
For example, if I go to my channel, pages, and to an entry under this channel i.e: /pages/some_page
What’s this entries function supposed to look like to pick up the “some_page” (short_name) entry? I only find the attribute entry_id=X. But that requires an ID.
Do I have to write my own php function to a lookup of what ID the short_name “some_page” belongs to?
Or is there a smarter, built-in, way of doing this?
Also, as an example. If I install the default example template agile records and click on “read more” for a news entry, I am sent to /news/comments/name_of_entry and then it displays comments. How do I make it just /news/name_of_entry. Because, if I try that now I get a 404 page not found.
If I learn how to do this, I feel I know enough to create the rest that I need.
Hi, Swedie -
Have you seen my series on The Importance of Semantics? If you read from bottom to top, it goes over all of these in a bit more detail, including sample code so you can follow along.
Thank you. I’ve understod now that that the exp:channel:entries is a smart function that can be tweaked to act as wanted 😊
Now, I’ve managed to display: /pages/test (where test is the short_name of an entry)
So let’s expand on this.
Say I wanted to go deeper: /pages/test/this/cool
How, is that that setup in the CMS bit of it all? 2 more entries named “this” and “cool”, but how do I put them under the entry “test” so the CMS understands this?
Another thing I would like help with, while the experts are around 😉
I’ve tried the exp:channel:categories function. This is the code in my header-template: {exp:channel:categories channel="pages"} {category_name} {/exp:channel:categories}
It spits out the path like this /pages/C9
This URL displays the entries that I have under that category. But why is it named C9? Can’t it be named in a better and more SEO friendly way?
Definitely read through Lisa’s articles - some really useful stuff there. If you want a hierarchy of pages, you can use the built-in pages module. You basically add an entry, then manually type the url you want it to have, and the template you want it to use. Note that if you want a ‘smart’ navigation where it automatically displays the hierarchy in a menu, you’ll need to use either ‘Navee’, ‘Taxonomy’ or ‘Structure’ - 3rd party add-ons that make this much easier.
Note that you can use conditionals in your templates, to show different content based on the url, which still in the same template. Eg. {if segment_3}do this{/if} or {if segment_2 == 'test'}do this{/if}
Categories - again Lisa has some good stuff on this here - http://ellislab.com/blog/entry/the_importance_of_semantics_displaying_categories/ But the main thing to understand is that EE can display categories as /C9 or /category/cat_url_title. In theses cases the ‘C’ or the word ‘category’ are the triggers, which tells EE to limit the channel entries loop to a particular category. In the settings (admin > channel admin > global prefs) you can tell EE which method to use.
I must excuse myself. I did go to Lisa’s page but I went only to the article about static pages. I didn’t scroll down further to read on the categories function. I found there what I needed to change the behavior of the category listing function.
From reading (or misreading) I expected EE to accept this URL: /channel/category/category_name/entry_in_that_category Where “category” is the default global preference for detecting categories… but it doesn’t work. Why?
But this works! /pages/entry_name (pages = channel name, entry_name = any entry under Pages, no matter category depth)
Lead me! Guide me to the right documentation where this is explained and / or example code for how to get this to work.
Either way, I have bought NavEE as it seem to do a great job of doing what I want. But I’d still like to know how EE wants things served.
PS… I’ve enabled strict URL:s so any missing or not correct URL is sent to a custom 404 page (template). Otherwise as expected it defaults back to the first entry of the channel or category.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.