I have used channels for different sections of a website, however I have noticed that if a channel entry has the same URL title of another entry in a different channel the url_title
field is not automatically incremented and the first entry results in a 404 error. Is there a way to automate this? This occurs even if a category url title is the same as a entry.
For example; I have 2 channels, your-life and a-z; I have a category called contraception in your-life and an entry in a-z named contraception, both have the url_title
"contraception".
When I leave them both at contraception, the SQL for the your-life category is as below, and the entries in this category do not appear:
SELECT DISTINCT(t.entry_id) FROM exp_channel_titles AS t
LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id
LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id
LEFT JOIN exp_members AS m ON m.member_id = t.author_id
INNER JOIN exp_category_posts ON t.entry_id = exp_category_posts.entry_id
INNER JOIN exp_categories ON exp_category_posts.cat_id = exp_categories.cat_id
WHERE t.entry_id !='' AND t.site_id IN ('1') AND t.entry_date < 1403708810 AND (t.expiration_date = 0 OR t.expiration_date > 1403708810) AND t.channel_id = '17' AND t.url_title = 'contraception' AND exp_categories.cat_id = '35' AND t.status = 'open'
ORDER BY t.sticky desc, wd.field_id_97 asc, t.entry_id asc
LIMIT 0, 100
#APP/modules/channel/mod.channel.php L:277 Channel::build_sql_query()
and if I change the url_title
for the a-z entry to "contraception1", the SQL is as below, and the entries in the category are shown
SELECT DISTINCT(t.entry_id) FROM exp_channel_titles AS t
LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id INNER JOIN exp_category_posts ON t.entry_id = exp_category_posts.entry_id
INNER JOIN exp_categories ON exp_category_posts.cat_id = exp_categories.cat_id
WHERE t.entry_id !='' AND t.site_id IN ('1') AND t.entry_date < 1403709091 AND (t.expiration_date = 0 OR t.expiration_date > 1403709091) AND t.channel_id = '17' AND exp_categories.cat_id = '35' AND t.status = 'open'
ORDER BY t.sticky desc, wd.field_id_97 asc, t.entry_id asc
LIMIT 0, 100
#APP/modules/channel/mod.channel.php L:277 Channel::build_sql_query()
EDIT//
{if embed:layout == 'Horizontal'}
<section class="container listing-block">
<div class="col-xs-offset-1 col-xs-10">
{exp:channel:entries channel="{embed:segment_1}" category="{embed:category_id}" orderby="yh_order" sort="asc"}
<article class="listing">
<div class="main-image">
{yh_images}
{yh_images:yh_listing_image}
<img src="{path}_listing/{filename}.{extension}" alt="{title}">
{/yh_images:yh_listing_image}
{/yh_images}
</div>
<div class="listing-inner">
<h2><a href="{title_permalink='{embed:segment_1}/single'}">{title}</a></h2>
<a class="btn btn-primary pull-right" href="{title_permalink='{embed:segment_1}/single'}">View more</a>
</div>
</article>
{/exp:channel:entries}
</div>
</section>
{if:elseif embed:layout == 'Vertical'}
{exp:channel:entries channel="{embed:segment_1}" category="{embed:category_id}" orderby="yh_order" sort="asc"}
<section class="container pageBlock">
<div class="col-xs-offset-1 col-xs-10 panel pageBlock-{yh_colour}">
<h1 class="text-center">
{yh_icon}
<img src="{path}_button/{filename}.{extension}" alt="{title}">
{/yh_icon}
{exp:filthy}{title}{/exp:filthy}
</h1>
<article class="panel-body">
{yh_leader_text}
<a href="{title_permalink='{embed:segment_1}/single'}" class="center-block btn btn-{yh_colour} filthy">Read more</a>
</article>
</div>
</section>
{/exp:channel:entries}
{if:elseif embed:layout == 'Icons'}
{exp:channel:entries channel="{embed:segment_1}" category="{embed:category_id}" orderby="yh_order" sort="asc"}
{if count == 1}
<section class="container {if total_results % 3 == 0}fundraise-links{if:elseif total_results % 5 == 0}home-links{if:else}home-links join-in-links{/if}">
<div class="row col-xs-offset-1 col-xs-10">
<ul>
{/if}
<li class="text-center {yh_colour} fader">
<div>
<a href="{title_permalink='{embed:segment_1}/single'}">
{yh_icon}
<img src="{path}_button/{filename}.{extension}" alt="{title}">
{/yh_icon}
<h2 class="filthy">{exp:filthy}{title}{/exp:filthy}</h2>
</a>
</div>
</li>
{if count == total_results}
</ul>
</div>
</section>
{/if}
{/exp:channel:entries}
{/if}
template_group/template
?!dynamic
parameter is what you're looking for.