How do I specify that I want the channel entries tag for the current URL title? I have a channel ‘regularPage’, and several paths. For instance, how would I specify if the URL title is “/about”, what parameter would I use in the Channel Entries tag?
{exp:channel:entries}
{/exp:channel:entries}
All of the available parameters for the channel:entries tag pair are in the docs..😉 https://ellislab.com/expressionengine/user-guide/add-ons/channel/channel_entries.html#parameters
However there is no need to force-feed the url_title to the channel:entries tag. It will dynamically grab it from the URL unless you tell it NOT to by specifying “dynamic=”no”.
I have an ‘about’ channel. It has a subpage Mission + Vision, (mission-vision). mission-vision is also under channel ‘about’, the URL title for the entry is ‘mission-vision’. However, when a go to URL site.com/about/mission-vision I get a 404 error…
going to /about works, but not the subpage.
Generally in EE you shouldn’t need content-specific templates.
In other words you should have the About channel with a Mission-Vision entry, but you should not need a template just to display the mission-vision entry. Going down this path means an EE install loaded with 2-4X the number of templates necessary (I just had to do some optimization on a site built in this fashion yesterday).
Is the content on about/index any different in structure from about/mission-vision? If not delete the mission-vision template and let the about/index present the content. This way you can publish a new page by just publishing an entry in the About channel. The existing templates would automatically handle it.
You’ll need to let go of the page/sub-page thinking with EE. EE doesn’t really handle content in that way. You have channels filled with entries, and create templates to pull out that content in different ways. But to EE one entry is not necessarily equal to one page. One entry may be one FAQ question & answer and all entries get pulled out to one page. Or one page for each. Or both.
On the 404 error - have you removed index.php from your urls?
Both ‘about’ and ‘mission-vision’ use the same template. I am using 1 template for this. I’m assuming my .htaccess is removing the index.php because it goes to / and /about correctly
This is ok:
www.mysite.com/about
This is a 404:
www.mysite.com/about/mission-vision
The both are built with the ‘site/index’ template, but they have embeds that use the entry id for specific content.
You lost me…
You have a site index template that is creating /about? Why?
You don’t have an about template group with an index template with a channel:entries tag pulling the about content?
It all sounds like you are working too hard and not letting EE do what it was designed to do. You shouldn’t have to specify entry ids or url_titles to get EE to display content - and this type of setup is harder to update and maintain going down the road.
Here is an excerpt from my site/index template. ‘embeds/page’ uses pageid to get the specific content.
{exp:channel:entries}
{if type != "dept"}
<div class=”page” id=”section3”> {embed="embeds/page" pageid="{entry_id}”} {embed="embeds/footer"} </div>
{/if}
{/exp:channel:entries}
from ‘embeds/page’:
{exp:channel:entries entry_id="{embed:pageid}”}
Yea, that’s really not a great build approach. You’re causing EE to run 2x the queries than is really necessary (with nested channel:entries loops), making a harder to maintain site going forward, and causing a lot of headaches with URLS.
I’d suggest perusing the Portfolio series I’ve been writing:http://www.train-ee.com/courseware/free-tutorials/category/building-a-portfolio-site
It’s not 100% done yet but enough is there that you’ll get the general idea of how to implement a site that lets EE work the way it wants to.
I’ll look into your add-on. I was using the Structure Add-on, but it was causing problems when I used drag and drop. I stopped using it and wrote a PHP include with an array for the navigation. So I’m writing a complex structure without using Structure.
The page loads if I just use “mysite.com/mission-vision”, but really it is a subpage of “about” so it should load with “mysite.com/about/mission-vision”. Structure makes this easy but it seems ‘dangerous’ to use. What do you think? I don’t know who to ask so if you could help that would be great. Thanks.
I don’t have any add-ons…the link is to tutorials that show how to generally use native EE code to build sites.
I’m not a great fan of Structure. I haven’t used it extensively but it’s more of a philosophical issue in that EE isn’t a page/hierarchical CMS and Structure forces it to be.
In your case create an About template group. In the index template write a channel:entries tag pair specifying the About channel. Load it at /about/missions-vision and the content should come up.
Navigation can be built by using another channel:entries tag pair pointed at the About channel and just pulling title/entry title. Set this one to dynamic=no so it doesn’t read the URL.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.