Having no entries in a target gallery (not sure if this affects weblog) will throw a fatal error. To fix, add this:to your lang.multi_relationship.php file, then, line 272 of ext_multi_relationship.php should look like this:'no_related_entries' => 'No entries exist yet',
Alternatively wait for an official bug fix. Sorry Mark just call me impatient 😊global $DB, $DSP, $EXT, $LANG;
What exactly does this do? Can you then call it from the template?
Mark, folks - I’m almost over the moon, but not quite…
Was there a final answer regarding the related entry tags throwing out
{REL[6][items]KDtQ0qxfREL}
instead of the titles of the related entries?
I’ve been banging my head against a wall on this for hours. Using latest EE 1.5.2 and latest Multi relationship extension 1.3 from top of this thread. Throws this code whether you relate one or multiple entries.
Here’s my code for my custom field {items} which pulls in multi-relationship data:
<ul>
{related_entries id="items"}
<li><a href="http://{title_permalink=">{title}</a></li>
{/related_entries}
</ul>
@Colly: Is this a gallery or weblog relation? Do you have any other non-default plugins/extensions/modules running on the template? I’ve found that most of the time when this happens it’s because either the id=”” is spelled wrong, there’s a space after the id=”” attribute or no entries have been selected for a relationship. Have you selected a related “item” for the entry your viewing?
Cheers Mark.
Weblogs, not galleries. Using Favorites module, ez_rate module, form_helper plugin. Need all of these (super-complex food database site). Can’t disable any as too much data to lose.
Just double-checked again, and id of custom field for relationship is correct, no naughty spaces, and the entry I’m testing has two entries (also tested with one) related to it.
So close to the perfect solution. Even tried it with queries based on Display SQL output - no joy.
Alright, version 1.0.4 is at the top of the thread. There have been a lot of questions about {REL /} tags being inserted into peoples code. THe reason for this is that EE is using the PHP function “call_user_func_array” function which as of PHP5 will pass by reference, but as of PHP4 will not. So, if you’re running PHP4, which I would guess a lot of you are, you can install the new extension. Then open up the ext.multi_relationship.php file and follow the instructions in the top of the file.
I’ve copied an pasted the code here for easier copying.
<pre><code>Open your /system/modules/weblog/mod.weblog.php file and find from this line:
// -------------------------------------------
// 'weblog_entries_tagdata' hook.
to this line:
//
// -------------------------------------------
Replace between those comments with this:
if (isset($EXT->extensions['weblog_entries_tagdata']))
{
// -- PHP4 Fix For call_user_func_array not passing by reference
global $Weblog; $Weblog = $this;
// -- End Fix
$tagdata = $EXT->call_extension('weblog_entries_tagdata', $tagdata, $row, $this);
if ($EXT->end_script === TRUE) return $tagdata;
// -- PHP4 Fix For call_user_func_array not passing by reference
$this = $Weblog; unset($Weblog);
// -- End Fix
}[/code]
First, thanks to all for help with this. I have done a bunch of work with the query module and got this to work – sort of.
{exp:query sql=”SELECT title as related_title, url_title as related_url, entry_id FROM exp_weblog_titles LEFT JOIN exp_relationships ON exp_weblog_titles.entry_id = exp_relationships.rel_child_id WHERE exp_relationships.rel_id = ‘{Stores}’”} {related_title}<br> {/exp:query}
I have a main blog called Products and two related blogs called stores and brands. This is running on Products page and I am trying to link over to the associated stores.
My problem with the above query is that it’s only returning the first item in the multi-list. Could anyone explain how to get the query to pick up everything in the multi-relationship list?
Thanks again.
–Scott
@bshersey: Is there a reason that you don’t want to just use the {related_entries /} tag? It seems to me you’re trying to recreate that, only your way won’t have the built in caching that the {related_entries /} tag provides. Also, what is the {Stores} tag. Is it a multi-relationship? If so then you’ll need to use some PHP to convert the return delimited list into a comma delimited list and then place that in a MySQL ‘IN’ statement like so:
rel_id IN (<?php explode(",", preg_split("/[\r\n]+/", "{Stores}")); ?>);
Of course doing it this way also requires PHP’s parsing stage to be set to input so it can run before the EE Template class does.
Hi Mark,
Thanks for your response. To answer the questions…
1.) Yes, it is using your multi-relationship extension. I keep getting those gibberish responses whenever I use the {related entries} tag. I have upgraded to your newest build. I haven’t checked, however, to see what version of PHP is being used. It is a pMachine-hosted site, so I assumed it was the latest. But I have not checked. So I tried to do it with the query.
2.) The main blog is Products. It calls sub-blogs Stores and Brands using your multi-relationship extension. {Stores} is the field I use in Products to call the content from the Stores blog. BTW, if I simply call {Brands} or {Stores}, it delivers IDs to me. The numbers seem to correspond with the number of items I have picked from each multi-relationship field in the main blog. But I haven’t tried to break them up.
3.) I did notice that no matter how I called the information, it was giving me multiple numbers as a single list/string. I assumed I had to break it somehow, but I am not a PHP expert. So thanks for the code sample.
However, it seems like if I can make the {related_entries} tag work, it would be easiest.
Thanks again,
–Scott
Mark, is there any way to set the order for the related entries using this extension? I think right now it uses the order set via the custom field configuration which only allows for title and date, but I’d like to sort the output by a custom field.
Example:
{related_entries id="my_field" order_by="my_custom_field"}
{my_custom_field}
{/related_entries}
I guess the other way would to throw everything in a php array and sort it that way but I thought I’d ask. Thanks!
I’m just upgraded to 1.0.4 and have found that clicking “Quick Save” loses the settings for the mutil-relationship area. Is this a bug? I was also having this problem in 1.0.1, which I was using until this morning.
Also, I’m on PHP 5. I tried adding that tweak you mentioned to the mod.weblog.php file because the server on which this site will reside when live is definitely running PHP 4, but get an error:
Fatal error: Cannot re-assign $this in /Users/me/Sites/mysite/system/modules/weblog/mod.weblog.php on line 2801
Does this tweak NOT work on 5? If so, will I have to make this change to that file once I go to the live server? Thanks for your help - this extension really has saved me on my current project. Wish I could get the setings to stick when clicking “Quick Save”, though!
Sorry to “bump” this, but the client just started updating the products on the dev site and found that all the multi-relation entries were forgetting themselves - and it turns out it was because they were indeed using the Quick Save button. I told them to click “Update” instead for right now.
Is this a known problem? I really need to use this extension on that particular site - I’m not sure how I will complete that site without it!
Mdesign: You could always remove the “quick save” button using this extension.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.