1 of 10
1
Multi Relation
Posted: 21 October 2006 11:31 AM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

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.

File Attachments
ext.multi_relationship_106.zip  (File Size: 4KB - Downloads: 904)
 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 30 October 2006 02:48 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

Update: version 1.0.1 fixes a bug when relating entries to galleries.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 18 November 2006 06:26 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  5
Joined  10-02-2006

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

Profile
 
 
Posted: 18 November 2006 01:13 PM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

smorello, version 1.0.2 should fix that problem.  grab it at the top of the thread.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 19 November 2006 04:21 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  5
Joined  10-02-2006

Thanks a lot for your reactivity !

Profile
 
 
Posted: 19 November 2006 10:04 AM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

No problem.  Glad the update helped.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 November 2006 09:29 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  5
Joined  03-06-2006

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?

Profile
 
 
Posted: 21 November 2006 09:53 PM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

Are you using reverse related entries?  I haven’t tested this going reverse.

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 22 November 2006 01:27 AM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  5
Joined  03-06-2006

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

Profile
 
 
Posted: 22 November 2006 01:36 PM   [ Ignore ]   [ # 9 ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  02-02-2006

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.

Profile
 
 
Posted: 24 November 2006 09:24 AM   [ Ignore ]   [ # 10 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1089
Joined  03-22-2006

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 smile

 Signature 

(a.k.a the_butcher)

Profile
 
 
Posted: 25 November 2006 06:05 PM   [ Ignore ]   [ # 11 ]  
Summer Student
Total Posts:  5
Joined  03-06-2006

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

Profile
 
 
Posted: 30 November 2006 12:21 AM   [ Ignore ]   [ # 12 ]  
Lab Assistant
RankRank
Total Posts:  187
Joined  09-14-2005

Thanks for the great extension! We need away to unselect all entries in the multi-field so that the value is recognized as NULL in our templates.

 Signature 

Chris Shontz
Official Tech Support Nuisance
Chris’s Flickr Photos

Profile
 
 
Posted: 30 November 2006 08:33 AM   [ Ignore ]   [ # 13 ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  02-02-2006

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.

Profile
 
 
Posted: 30 November 2006 11:16 AM   [ Ignore ]   [ # 14 ]  
Lab Assistant
RankRank
Total Posts:  187
Joined  09-14-2005
Jacob Fentress - 30 November 2006 08:33 AM
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. smile

 Signature 

Chris Shontz
Official Tech Support Nuisance
Chris’s Flickr Photos

Profile
 
 
Posted: 30 November 2006 06:50 PM   [ Ignore ]   [ # 15 ]  
Lab Assistant
RankRank
Total Posts:  187
Joined  09-14-2005

Okay, here’s another one - can you implement a way to configure the height of the multi-select field? I’m browsing through around 1000 entries, and I find it awkward to use in its current form, viewing only 6 lines at a time. What do ya think?

Thanks again! smile

 Signature 

Chris Shontz
Official Tech Support Nuisance
Chris’s Flickr Photos

Profile
 
 
Posted: 02 December 2006 11:11 PM   [ Ignore ]   [ # 16 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006
the_butcher - 24 November 2006 09:24 AM

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 smile

What exactly does this do?  Can you then call it from the template?

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 03 December 2006 12:24 AM   [ Ignore ]   [ # 17 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

Version 1.0.3 works with reverse related entries and allows you to set the height of the select box.  Grab it at the top of the thread.
Mark

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 03 December 2006 11:24 AM   [ Ignore ]   [ # 18 ]  
Grad Student
Avatar
Rank
Total Posts:  97
Joined  07-06-2006

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="{title_permalink="products/detail"}">{title}</a></li>
{/related_entries}
</ul>

 Signature 

Erskine Design: http://www.erskinedesign.com
“Grad student”? - we’ve been here since the start!

Profile
 
 
   
1 of 10
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 10:33 AM
Total Registered Members: 62691 Total Logged-in Users: 31
Total Topics: 77272 Total Anonymous Users: 15
Total Replies: 417102 Total Guests: 165
Total Posts: 494374    
Members ( View Memberlist )