@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?
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.
Open your /system/modules/weblog/mod.weblog.php file and find from this line:
if (isset($EXT->extensions['weblog_entries_tagdata'])) { // -- PHP4 Fix For call_user_func_array not passing by reference global $Weblog; $Weblog = $this; // -- End Fix
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?
@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.
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.
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.
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!
I know I can disable it - but I and my client ACTUALLY like quick save. I know a lot of people can’t stand it, but I don’t understand why. If you’re working on a draft, and you have a big content area with a lot of HTML or Textile formatting - it allows you to make incremental tweaks and keeps you right there, on the entry, to keep tweaking. I know it’s only saving a click each time (after hitting update, you then click on “Edit this Entry” on the next screen...) but I find saving a click to be handy and a wee bit faster (because I always have at least two tabs open, or two windows, with the admin area in one, and the live/or dev site in the other). Make a tweak, hit quick save, switch to other window, refresh. Repeat until perfect.
I just think, instead of installing two extensions to make one work right - the one should work right!
#$(*&^#$ - I just lost a really long post trying to spell check the damn thing. ARRGH.
ANYWAY - briefly, this extension is also losing settings when another unrelated but required field is not filled in and EE throws an error. So - this doesn’t appear to work with quicksave, and it doesn’t appear to work when EE throws an error (i.e. for a required field).
Questions:
Is anyone else using this, and experiencing these same issues? If you are not using this, how are you managing your relationships? I’d like to get this resolved on some level before going too far along with the build of this site.
It’s worth noting that the odd {REL} behavior apparently sometimes happens even if you ARE running PHP 5—i’m on 5.2.1, and had the same issue.
However, your fix to mod.weblog works for me too! Just thought i’d contribute that you might try the fix even if you’re NOT on PHP 4, if you’re having the issue!
I have Weblog A (classes) and it relates to Weblog B (teachers).
I deleted a teacher from the weblog “teacher”. This teacher that I deleted was connected to a class in the “classes” weblog. When I listed the class the teacher still showed up even though they had been deleted. I had to go in and do an edit on that class to “break” or remove the linking.
Is there a setting that I need to explore or is this a bug?