1

I want to remove template name from URL. I want to display only template_group/entry-name. Is this possible?

4

You can use the Template Routes plugin to override the default routing.

You'd add something like this to your index.php:

$config['template_routes'] = array(
  'template_group/:any' => 'template_group/template_name'
);

and then just do something with the $1 value in the template.

3

As Robson & Bhashkar have stated, use the index template in the template group to do the channel:entries tag pair - therefore doing away with the template reference in the URL. If you target template_group, it automatically uses the index template without you specifying /template_group/index.

You're trying to utilise the same template (template_group/index) for both the listing and the details - that's absolutely fine, just utilise no_results...

Let's assume template_group is "blog", the URLs you want are:

  • /blog (listing)
  • /blog/my-article (details - not /blog/details/my-article)

Assume you're accessing the entry details first, so blog/index template:

{exp:channel:entries
    channel="blog"
    dynamic="yes"
    require_entry="yes"
    track_views="one"
    disable="member_data|pagination"}
    {if no_results}
        {embed=blog/listing}
    {/if}

... display of blog details page   ...

{/exp:channel:entries}

This will attempt to pull an entry based on the URL - if it can't match it, it will fall into the no_results conditional and embed the listing page...

Template blog/listing (note this template isn't the URL!)

{exp:channel:entries 
    channel="news"
    dynamic="no" 
    orderby="date"
    sort="desc"
    paginate="bottom" paginate_base="/blog"
    limit="10"}

    ...listing details...
{/exp:channel:entries}
0

The easiest way will be just put the code within the "index" template of that template group. By doing it, you can have the URL like template_group/entry-name.

  • @ Bhashkar sir i am already using "index" template for article list page and for article detail page i am using template_group/template/article-name so now i want to remove details and i want to use template_group/article_name now how this is possible ? – Bhavin Vora Oct 15 '13 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.