Alright, I know people have been asking for this so I put together a “Multi Relationship” extension that adds another custom field type providing one to many relationships. It behaves the same as any other relationship and uses the same syntax. Anything you specify in a normal relationship should be valid here. The only difference being the code between the ee tags will repeat for as many entries as you selected.
<ul>
<li class="colhead"><strong>Related Entries</strong></li>
{related_entries id="mrelation"}
<li>{title}</li>
{/related_entries}
</ul>
Caution: This extension will only work with EE 1.5.0. Unless the friendly folks at pMachine can help me figure out how to access the Weblog object from the extension. (The third parameter for weblog_entries_tagdata - $this - was only added in version 1.5).
Not Working? Read the top of the extension .php file. There is a workaround if you are running a PHP version <5.
Hello and first thanks for your extensions.
I have a problem where i can’t find solution.
When i have a field with a multi relationship, if i don’t select a relationship for an entry in the list , there is {REL[][related_services]kWAujMlsREL} displayed for {related_entries id="myfield"}{/related_entries}
Is there a way to test or count the number of related_entries ?
Thank you
Samuel
I am getting that same weird code showing up when I try to use the multi-relationship extension.
{REL[31][Brands]565MMlT6REL}
I think I am doing everything right. My reverse relationship tags are working.
I can see the textarea fields with all my choices in them when I edit an entry. I am using Shift/Click to highlight multiple lines.
And I am using version 1.02, as discussed in the forum.
What would make this happen?
Here is the URL: http://www.allergyfreegroceries.com
Click on product listings. This is where I am using straight related entries using your extension and getting the strange code. Click on stores or brands. These are using reverse related entries for the secondary items and seem to be working fine.
The template code is standard related entries code in all cases.
Thanks for your help.
–Scott
Mark,
Thank you for the excellent extension - I’ve been wanting something like this for a long time.
One question. Is there any way to implement a way to count the number of relations?
Specifically, I’m trying to do show a list of guests (for a radio program), but I want it to be in sentence format, with commas in the appropriate places. The code I’ve attempted is as follows:
{related_entries id="guests"}
{if count == total_results}<a href="http://myurl.com/radio/guests/{entry_id}">{title}</a>{if:else}<a href="http://myurl.com/radio/guests/{entry_id}">{title}</a>, {/if}
{/related_entries}
Unfortunately, the count for every entry comes out to “1” - at least that’s what I get if I try {count}, so the above code always assumes each count equals the total results because the count and total results show up as “1” even if there are 2 or 15 guests.
Do you have any workarounds for this?
Thanks again for your work. I’ve installed several of your extensions over the past week - all of them excellent.
Having no entries in a target gallery (not sure if this affects weblog) will throw a fatal error. To fix, add this:
'no_related_entries' =>
'No entries exist yet',
to your lang.multi_relationship.php file, then, line 272 of ext_multi_relationship.php should look like this:
global $DB, $DSP, $EXT, $LANG;
Alternatively wait for an official bug fix.
Sorry Mark just call me impatient 😊
First, thanks for all of your suggestions. I have been trying to implement all of them. But I am still stuck.
I made the adjustments suggested to the extension files, but I still get the errors.
So I tried Mark’s checkboxes extension. Those seemed to work. I could set up multiple choices and they all showed up, with no gibberish code.
But then I tried to use the query module to create a link back to the related blog that I am calling with the checkboxes. From looking at other code samples and playing around with it, I figured I needed to call exp_weblog_titles and grab {title} and {url_title} to create the link. Using joins, it looks like I need to add in the entry_id from the weblog_data table and child id from the relationships table. All of this works fine. But I am looking for a unique ID to call for this specific item(s). It looks like the rel_ID in the relationships table could work, and I have seen some sample code in these forums that matches the relationships rel_id to a specific field in the weblog_data table.
One problem. My rel_id is a number. The corresponding field in the weblog_data table is a name. So they aren’t comparable in this state.
Is there a way to convert one or the other? Or is there something here that I am missing?
Here’s a good example of some code I picked up and was trying to adjust:
SELECT url_title as brand_url FROM exp_weblog_titles LEFT JOIN exp_relationships ON exp_weblog_titles.entry_id = exp_relationships.rel_child_id
All of the above works fine. But I need that unique ID for this particular entry. I want to make a WHERE clause like this one:
WHERE exp_relationships.rel_id = ‘x’ //where x is the field. But the corresponding rel_id in the field I am looking to match is a number: 62.
Or I could write something without a join like (forgive me if this isn’t exact since I am trying to recreate it here from my head since I wiped my earlier tries out):
SELECT exp_weblog_titles.url_title, exp_weblog_data.entry_id, exp_relationships.rel_id, exp_relationships_childid FROM exp_weblog_titles, exp_weblog_data, exp_relationships WHERE exp_weblog_titles.entry_id = weblog_relationships.childid AND exp.relationships.rel_id = exp_weblog_data.field1).
But once again I run into the problem here that I have one number and one field name. Could someone tell me what I am missing here?
Basically, I am trying to create relationships, with cross-referencing. The main blog is named Products. The sub-blogs are Brands and Stores. I want someone on the products page to be able to click on either specific related Brands or Stores to see all the existing relationships on every page. Then on the Brands page or the Stores page, they should be able to click to see all related products, etc. etc.
Thanks in advance. Previously, I would have done this with ASP and Access. But I think EE will be much easier, once I get this theory down.
–Scott
Chris,
I believe you can already unselect entries. If you only have one entry selected (and if you have multiple, click on one to unselect the rest), then hold ctrl (command on mac) and click on that one selection to unselect it.
When you don’t have any entries selected, you can use something like:
{if products != ""}
to check if the field is empty or not. Of course my field in this case is named “products.”
I hope that helps.
I believe you can already unselect entries. If you only have one entry selected (and if you have multiple, click on one to unselect the rest), then hold ctrl (command on mac) and click on that one selection to unselect it.
OMG - I should’ve known. Thanks, Jacob! It was 12:30 AM - I was runnin’ on empty when I posted that question. 😊
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.