Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The related_categories_mode does not return category data #2135

Closed
wardourdigital opened this issue Jul 10, 2022 · 0 comments
Closed

The related_categories_mode does not return category data #2135

wardourdigital opened this issue Jul 10, 2022 · 0 comments
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on.

Comments

@wardourdigital
Copy link

When I use the related category mode, there is no category data returned.

{!-- Main Entry --}
{exp:channel:entries channel="news" url_title="{segment_2}" track_views="one" dynamic="no" disable="pagination|member_data|trackbacks" status="open|featured"}
	{title}
{/exp:channel:entries}

{!-- Related Cat Mode Loop --}
{exp:channel:entries channel="news|events|media|briefs|partner_content|media" related_categories_mode="yes" limit="3" custom_fields="yes" dynamic="no" url_title="{segment_2}"}
	{title}

        {!-- This does not work --}
	{categories show_group="6|7|8" limit="1"}
		<a class="content-card__category" href="category/{category_url_title}">{category_name}</a>
	{/categories}
	
{/exp:channel:entries}

Describe the solution you'd like
The category data to be returned when using the standard {categories} tag.

Describe alternatives you've considered
I have used the Query add-on to generate the query needed to pull in the category data.

{exp:query sql="SELECT `c`.`cat_id`, `c`.`cat_name`, `c`.`group_id`, `c`.`cat_url_title` FROM (`exp_channel_titles` t) INNER JOIN `exp_category_posts` p ON `p`.`entry_id` = `t`.`entry_id` INNER JOIN `exp_categories` c ON `p`.`cat_id` = `c`.`cat_id` WHERE `c`.`cat_id` IS NOT NULL AND `t`.`site_id` IN (1) AND `t`.`url_title` = '{segment_2}' AND `c`.`group_id` IN (6,7,8) LIMIT 1"}
   <a class="content-card__category" href="{path='category/{cat_url_title}'}">{cat_name}</a>
{/exp:query}

This is very verbose!

Possible solution

I have seen in the mod.channel.php related_category_entries() ln, 4686 if the following is added before $this->parse_channel_entries():

if ($this->enable['categories'] == true) {
            $this->fetch_categories();
}

Then the {categories} tag works as expected. Is there any reason this cannot work?

@intoeetive intoeetive added the Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on. label Aug 17, 2022
intoeetive added a commit that referenced this issue Sep 6, 2022
…es-in-related-categories-mode

Resolved #2135 where categories were not parsed in related categories mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on.
Projects
None yet
Development

No branches or pull requests

2 participants