Is it possible to utilize {reverse_related_entries} tags and show the reverse related results by category? I’d like to have anchor tags that link to “domain.com/template_group/template/category/url_title” and limit the output to reverse related entries.
Is this possible? The following is not working for me…
I would like to link to a page that is pulling in the weblog data via reverse relationship. I’d like this data to be categorized based on the categories of the reverse related weblog.
For example:
I have a weblog called documents and these documents are reverse related to a weblog called projects. The documents have many categories. So, when I show all the documents associated with a particular project via reverse relationship tags, I’d like to be able to show the category they belong to. Make sense?
I want the URL structure to be: domain.com/templategroup/template/category/project OR domain.com/templategroup/template/project/category
And I’d like the page to have results:
category1:
list of documents
category2:
list of documents
category3:
list of documents
These results would be specific to the project they are related to.
EDIT/ADD: Also, I’d like to have a list of category links that filter the list based on the category. So, I don’t think I was completely clear in the above. I’d like a way to list documents “all” categories and then a way to list “by category”
{reverse_related_entries} <!-- if you have more relations then specify weblog="" --> <b>{title}</b> {categories} <i>cat: {category_name}</i> - {/categories} {if no_reverse_related_entries} <small><i>No reverse-related entries found (docs)</i></small> {/if} <br /> {/reverse_related_entries}
{/exp:weblog:entries}
This shows the docs for a project. I don’t see in the docs that you can order reverse_related entries by categories.
And with a category archive tag i can’t seem to find if you could limit to one related_entry
http://expressionengine.com/docs/modules/weblog/category_archive.html
I think you might end up with using a query… sorry i couldn’t help you more with this…
I hope someone with a bit more EE-finesse comes along
I really don’t know enough just yet about EE tags for this particular issue… i’ve spent a few minutes (*cough*) on this but what you want with these related entries and categories is a peculiar thingy. (Show all reverse-related docs from a project, grouped and ordered by or within a specific certain category). Hope some EE or EE-SQL guru comes by.
hi stephen, i’ve been following your progress on the project management thread and am looking forward to seeing it in action.
regarding the problem you are having in this thread, a query would definitely work. this would probably involve writing a small plugin to return the entries categorised and in the correct order. if you want help with this then let me know, i’d be happy to help out.
can you please clarify that this is what is supposed to happen:
given a project, all the documents that are related to that project should be returned, grouped into their appropriate categories
Ha, this response couldn’t have come at a better time. I’m sitting here in bed watching football and trying to figure this query out:)
Yes, I believe you got it. I’m attaching a screenshot that should help communicate what I’m needing. Each of the documents are single entries in a weblog called cs_planning. These documents are categorized. Also, these documents are related to a weblog called cs_projects.
stephen, after some testing of the code in the last post i realised that there were a few things missing. i’ve tested this code and it works for me so i hope its what you need. let me know if you have any questions or if i can help with anything else.
// assume that the project entry title has been provided $project_title = "Test project 1";
// 1. we get the entry id of the related project $sql = "SELECT entry_id FROM exp_weblog_titles WHERE title = '".$project_title."'"; $query = $DB->query($sql); $row = $query->row; $my_related_entry_id = $row['entry_id'];
// 2. we get the field id of the relationship field $sql = "SELECT field_id FROM exp_weblog_fields WHERE field_type = 'rel'"; $query = $DB->query($sql); $row = $query->row; $my_field_id = $row['field_id'];
// 3. we get all of the entries (joined with the categories and relationships) that are in the right weblog and that are related to the project and sort them by category id $sql = "SELECT * FROM exp_weblogs JOIN (exp_weblog_titles, exp_weblog_data, exp_category_posts, exp_categories, exp_relationships) ON exp_weblogs.weblog_id = exp_weblog_titles.weblog_id AND exp_weblog_titles.entry_id = exp_weblog_data.entry_id AND exp_weblog_data.entry_id = exp_category_posts.entry_id AND exp_category_posts.cat_id = exp_categories.cat_id AND exp_weblog_data.field_id_".$my_field_id." = exp_relationships.rel_id WHERE exp_weblogs.blog_name = 'cs_planning' AND exp_relationships.rel_child_id = '".$my_related_entry_id."' ORDER BY exp_categories.cat_id ASC";