We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Tied Entries

Development and Programming

Adam Khan's avatar
Adam Khan
319 posts
16 years ago
Adam Khan's avatar Adam Khan
So with your plugin, I’m assuming (hoping) I can from weblog 3 (a news entry) traverse thru the relationships weblog 3 > weblog 2 > weblog 1 and display data from weblog 1? Do you have plans on porting over to 2.0?

Yep, it’ll do that! And yes, it’ll be ported over to 2.0 sometime before Dec 1st.

       
hothousegraphix's avatar
hothousegraphix
851 posts
16 years ago
hothousegraphix's avatar hothousegraphix

Adam,

I’m finally getting around to using your plugin. I gotta say thus far, it’s been a lifesaver. Ever tried to organize reverse related results by category? OMG what a pain.

Tied Entries to the rescue! It seems that I can apply the “category” parameter to your tied entries tag, define a reverse relationship and spit out the results I’m looking for.

My man…I gotta give you your props! Thank you!

Got a question, is there a way to evaluate for and/or display category information?

For instance, currently my tied entries loop looks like:

{exp:tied_entries 
entry_id="{entry_id}"
weblog="campaign"
tie="<campaign" 
category="40|43|44|45"
status="Retired"
limit="5"
sort="desc"
}{if "{tied:count}"=="1"}<h3 class="content_heading">Seasonal Programs</h3>
    <ul>
        {/if}<li class="clearfix"><a href="#"><span><?php echo date("Y", "{tied:entry_date}"); ?>  </span>{tied:title}</a></li>
        {if "{tied:total_results}"=="{tied:count}"}

    </ul>
{/if}{/exp:tied_entries}

I’m hoping I can replace the {tied:title} varialbe with my entry’s {category_name}.

I have tested the standard usage of {categories}{category_name}{/categories} not really expecting it to work - and it didn’t.

Any advice?

Thanks

       
Adam Khan's avatar
Adam Khan
319 posts
16 years ago
Adam Khan's avatar Adam Khan

Michael,

Very pleased to hear that the plugin’s being useful. I hadn’t thought of using it to get around the lack of category filter in the related_entries and reverse_related_entries tags.

Adam, I’m hoping I can replace the {tied:title} varialbe with my entry’s {category_name}. I have tested the standard usage of {categories}{category_name}{/categories} not really expecting it to work - and it didn’t. Any advice?

That’ll take a bit of doing, variable pairs, but I see a way through to how it could be done. Will put it on the roadmap, but I wouldn’t expect it to be done within the next couple of weeks.

But it can be done meanwhile by passing the entry_id to an embedded template:

{exp:tied_entries 
entry_id="{entry_id}"
weblog="campaign"
tie="<campaign" 
category="40|43|44|45"
status="Retired"
limit="5"
sort="desc"
}{if "{tied:count}"=="1"}<h3 class="content_heading">Seasonal Programs</h3>
    <ul>
        {/if}<li class="clearfix"><a href="#"><span><?php echo date("Y", "{tied:entry_date}"); ?>  </span>{embed="site/.cat" entry_id="{tied:entry_id}"}</a></li>
        {if "{tied:total_results}"=="{tied:count}"}

    </ul>
{/if}{/exp:tied_entries}

And do a regular weblog:entries tag in the embedded template to get the categories:

{exp:weblog:entries weblog="campaign" dynamic="off" status="not closed" disable="custom_fields|member_data|pagination|trackbacks" entry_id="{embed:entry_id}"}
{categories}{category_name}{/categories}
{/exp:weblog:entries}

That’s a template with a weblog:entries tag per entry though, so it’s not very efficient server-wise.

       
hothousegraphix's avatar
hothousegraphix
851 posts
16 years ago
hothousegraphix's avatar hothousegraphix

OMG, I’ve been messing with trying to get my embed to display and wasn’t applying the

dynamic="off"

parameter.

That parameter kick’s my @#$! all the time. I always overlook it thinking my syntax is to blame.

I gotta step away from my keyboard!

Thanks again!

       
TonyNibbles's avatar
TonyNibbles
98 posts
16 years ago
TonyNibbles's avatar TonyNibbles

Hmmm, Looks interesting.

Does it work with MSM? Will it correctly pull out entries related between multiple sites?

       
Adam Khan's avatar
Adam Khan
319 posts
16 years ago
Adam Khan's avatar Adam Khan
Hmmm, Looks interesting. Does it work with MSM? Will it correctly pull out entries related between multiple sites?

Yes.

       
Luke Hardiman's avatar
Luke Hardiman
109 posts
about 16 years ago
Luke Hardiman's avatar Luke Hardiman

Oh dear, I can’t get this to work on EE 1.6.8, PHP 5. I have tried disabling all extensions.

I am trying to tie some reverse relationship fields together across a single weblog. In my template I have

{exp:weblog:entries weblog="locations"}

{title}

        {exp:tied_entries entry_id="{entry_id}" tie="<location_parent<location_parent"}
        {tied:title}

        {/exp:tied_entries}

{/exp:weblog:entries}

This kicks out the following warnings and errors:

Warning: ksort() expects parameter 1 to be array, null given in /[removed]/plugins/pi.tied_entries.php  on line 357

Warning: ksort() expects parameter 1 to be array, null given in /[removed]/plugins/pi.tied_entries.php on line 358

Warning: array_reverse() [function.array-reverse]: The argument should be an array in /[removed]/plugins/pi.tied_entries.php on line 364

Warning: array_reverse() [function.array-reverse]: The argument should be an array in /[removed]/plugins/pi.tied_entries.php on line 365

Warning: Invalid argument supplied for foreach() in /[removed]/plugins/pi.tied_entries.php on line 370

Warning: Invalid argument supplied for foreach() in /[removed]/plugins/pi.tied_entries.php on line 399
MySQL ERROR:

Error Number: 1064

Description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '3 ORDER BY d.entry_id' at line 1

Query: 3 ORDER BY d.entry_id ;

I poked around in the plugin and the $ropes_id and $ropes_type arrays are not being initialised prior to the ksort function calls which is where the problems begin.

       
Adam Khan's avatar
Adam Khan
319 posts
about 16 years ago
Adam Khan's avatar Adam Khan

Eep, that’s a lot of errors. Will go in and initialize what needs initializing and rerelease. Meanwhile, I haven’t tested using a single weblog. That might be the issue. Will take a look at that as well and get back to you here.

       
Adam Khan's avatar
Adam Khan
319 posts
about 16 years ago
Adam Khan's avatar Adam Khan

Not that reversing the arrows should create such a mess, but the problem is that your arrow is facing the wrong way in the tie; if it’s a related field, it’s a “>”, if it’s a reverse related weblog, it’s a “<”.

It should work if fix the tie syntax, but the debug option should be able to tell you that, and right now it can’t. Fixing…

At any rate, calling the same weblog is fine.

       
Adam Khan's avatar
Adam Khan
319 posts
about 16 years ago
Adam Khan's avatar Adam Khan

Luke, I’ve released an update that handles that particular type of tie parameter malformation, which wasn’t getting handled. Download Tied Entries v1.1.1

       
Adam Khan's avatar
Adam Khan
319 posts
about 16 years ago
Adam Khan's avatar Adam Khan

Luke, if you want to reverse relate, you can still use the “<” linker but need to follow it by the weblog name, not the field name.

       
Luke Hardiman's avatar
Luke Hardiman
109 posts
about 16 years ago
Luke Hardiman's avatar Luke Hardiman

Got it! Thanks Adam, I realised I hadn’t read the docs properly shortly after I posted - doh! Ta for the update though.

Actually what would be really great is if there were something like a recursive=”yes” option. What I have on this project (and several others actually) is a location hierarchy. Each location has a parent location which establishes it’s position in the hierarchy. In my templates, where I have a page listing stores in South Africa for example, I need to traverse down the tree to pull out all the stores at the child locations within South Africa.

This kind of feature would be super helpful for breadcrumb navigation as well and having searched around, it seems there is no EE addon which offers a recursive query solution. Maybe there is an opportunity for you to broaden the appeal of your addon?

       
Adam Khan's avatar
Adam Khan
319 posts
about 16 years ago
Adam Khan's avatar Adam Khan

I think recursion would only broaden the appeal to a very narrow range of perverse thinkers, but I’d be among them. Added to the plugin’s roadmap. Thanks for the feedback.

       
Luke Hardiman's avatar
Luke Hardiman
109 posts
about 16 years ago
Luke Hardiman's avatar Luke Hardiman

Great! Looking forward to it! Just to provide a use case for the above, this is what I currently have in my sandbox template to get the output we need:

{exp:weblog:entries weblog="locations"}

<h1>This parent is {title}</h1>

<h3>Tied Entries</h3>

<ul>

{exp:tied_entries entry_id="{entry_id}" tie="<locations" limit="10" search:gypsy_parent_location}
<li>{tied:title} (location) > {title}</li> 
{/exp:tied_entries}

{exp:tied_entries entry_id="{entry_id}" tie="<locations<locations" limit="10" search:gypsy_parent_location}
<li>{tied:title} (location) > Parent location > {title}</li> 
{/exp:tied_entries}        

{exp:tied_entries entry_id="{entry_id}" tie="<locations<locations<locations" limit="10" search:gypsy_parent_location}
<li>{tied:title} (location) > Parent location > Parent location > {title}</li>
{/exp:tied_entries}                

{exp:tied_entries entry_id="{entry_id}" tie="<branches" limit="10" search:gypsy_parent_location}
<li>{tied:title} (branch) > {title}</li> 
{/exp:tied_entries}        

{exp:tied_entries entry_id="{entry_id}" tie="<locations<branches" limit="10" search:gypsy_parent_location}
<li>{tied:title} (branch) > Parent location > {title}</li>
{/exp:tied_entries}        

{exp:tied_entries entry_id="{entry_id}" tie="<locations<locations<branches" limit="10" search:gypsy_parent_location}
<li>{tied:title} (branch) > Parent location > Parent location > {title}</li> 
{/exp:tied_entries}        

{exp:tied_entries entry_id="{entry_id}" tie="<locations<locations<locations<branches" limit="10" search:gypsy_parent_location}
<li>{tied:title} (branch) > Parent location > Parent location > Parent location > {title}</li> 
{/exp:tied_entries}        

</ul>
        
{/exp:weblog:entries}

The weblog names in brackets are hard coded as I couldn’t get {tied:weblog} or {tied:weblog_short_name} to ouput a value.

If we could rather do something like this, that would be totally spectacular:

{exp:weblog:entries weblog="locations"}

<h1>This parent is {title}</h1>

<h3>Tied Entries</h3>

{exp:tied_entries entry_id="{entry_id}" tie="<locations|branches" recursive="yes" recursive_limit="5" limit="10" search:gypsy_parent_location}
{if '{tied:count}' == '1'}<ul>{/if}
<li>{tied:title} ({tied:weblog}) {tied:parents} > {tied:parent_title}{/tied:parents}</li> 
{/exp:tied_entries}   
{if '{tied:count}' == '{tied:total_results}'}</ul>{/if}
        
{/exp:weblog:entries}

!

       
Bransin's avatar
Bransin
157 posts
15 years ago
Bransin's avatar Bransin

I thought this plugin would accomplish what I need to accomplish with reverse related entries.

It would be great to select which relationship field to filter by when using reverse related entries. Right now I have a weblog that has 2 relationship fields that perform different tasks but relate to the same weblog. How do I tell ExpressionEngine to find all reverse related entries by custom field?

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.