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

Get Channel Entries for URL Title

Development and Programming

motorstormer's avatar
motorstormer
17 posts
11 years ago
motorstormer's avatar motorstormer

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}

       
Boyink!'s avatar
Boyink!
5,011 posts
11 years ago
Boyink!'s avatar Boyink!

Two questions:

  • What options have you found in the docs?

  • Why are you wanting to force the url-title?

       
motorstormer's avatar
motorstormer
17 posts
11 years ago
motorstormer's avatar motorstormer

I don’t understand, nothing in the docs.

If I put ‘/about/staff’ in the URL title for an entry, I want it to go to that entry if the user goes to ‘/about/staff’ on the browser.

       
Boyink!'s avatar
Boyink!
5,011 posts
11 years ago
Boyink!'s avatar Boyink!

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”.

       
motorstormer's avatar
motorstormer
17 posts
11 years ago
motorstormer's avatar motorstormer

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.

       
Boyink!'s avatar
Boyink!
5,011 posts
11 years ago
Boyink!'s avatar Boyink!

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?

       
motorstormer's avatar
motorstormer
17 posts
11 years ago
motorstormer's avatar motorstormer

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.

       
Boyink!'s avatar
Boyink!
5,011 posts
11 years ago
Boyink!'s avatar Boyink!

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.

       
motorstormer's avatar
motorstormer
17 posts
11 years ago
motorstormer's avatar motorstormer

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}”}

       
motorstormer's avatar
motorstormer
17 posts
11 years ago
motorstormer's avatar motorstormer

Yeah, it’s a crazy site. It has five pages scrolling horizontally. So I use site/index to put the pages together. Maybe I need to approach it differently. Thanks for your help.

       
Boyink!'s avatar
Boyink!
5,011 posts
11 years ago
Boyink!'s avatar Boyink!

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.

       
motorstormer's avatar
motorstormer
17 posts
11 years ago
motorstormer's avatar motorstormer

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.

       
Boyink!'s avatar
Boyink!
5,011 posts
11 years ago
Boyink!'s avatar Boyink!

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.

       
motorstormer's avatar
motorstormer
17 posts
11 years ago
motorstormer's avatar motorstormer

I created an ‘about’ template group, and in the index template I have:

{exp:channel:entries channel="about"} {/exp:channel:entries}

but /about/mission-vision still returns a blank page

       
Boyink!'s avatar
Boyink!
5,011 posts
11 years ago
Boyink!'s avatar Boyink!

Remove your htaccess rules - I’d recommend waiting until the site is done before removing index.php - just for this reason.

Make sure your mission-vision entry is set to open, and doesn’t have an expiration date set in the past.

       
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.