Feel like I am flooding you guys with questions, sorry about that….
I am using Solspace Tags and using the following code to generate similar posts across my site. Works great!
Now I have multiple site manager and need to set up the code so it pulls, and automatically links back to the proper website, blog, url, etc. Any suggestions:
<h4>Similar Posts Across PVC</h4>
{exp:tag:related_entries entry_id="{entry_id}" dynamic="off" limit="5"}
<a href="http://{path={weblog}/story/{url_title}}">{title}</a>
{/exp:tag:related_entries}
I tried adding site=”default_site” like so: {exp:tag:related_entries entry_id="{entry_id}” site=”default_site” dynamic=”off” limit=”5”}
but no luck. Any suggestions?
Had to do some testing- but it looks like the site parameter does work in that tag. I have two sites: test and media_cowcom- using:
{exp:weblog:entries limit="1" status="not closed" disable="member_data|trackbacks"}
{title}
<hr>
<h4>Similar Posts Across PVC</h4>
{exp:tag:related_entries entry_id="{entry_id}" dynamic="off" limit="5" site="test|media_cowcom"}
<a href="http://{path={weblog}/story/{url_title}}">{title}</a>
{/exp:tag:related_entries}
{/exp:weblog:entries}
Pulls in all related entries from both sites.
Make sense? And does this do what you need?
Actually, in my post above, I forgot to place the site=”site1|site2” However, I did try that on my site.
Oddly enough, two strange things are happening: 1. This is the code I’m placing on the second site, and when I do, the only “similar article” it pulls, is the exact one being displayed on the page. In other words, it’s not finding other entries, only itself. 2. the other odd thing is that it’s not finding anything from the original site.
I’ve made sure all of the keywords are correct to rule that out as an issue.
So I’m not sure why it works on your site and not mine. Also, I tried the process installing this same code on my main site, seeing if it picks up the new site. It does not pick up the new site, but does work properly on this one site. In other words, it finds similar tags within the URL. But odd that the same code on the new site can’t even do that?
This is troubling for me as the unique selling point of my site is that I want all of the articles to be interrelated from site to site.
OK I did further testing…. I had tried numerous things on the new site to get it to work. One was copying your code with the {exp:weblog:entries limit="1" status="not closed" disable="member_data|trackbacks"} as part of it. That’s what cause the site to only pick up that article, not similar articles. That was proven on both sites.
Here’s the strange thing… on the main site, I tried something different completely, site_id=”9” and it sill pulled the normal related tags from the same site. What’s remarkable, is that there is no site with an id of 9. I only have 2 sites. So for whatever reason, the site= and site_id= aren’t working at all.
Perhaps if I can get that part fixed, the rest will fall in line.
I’m not dead sure site_id works as a variable. I was testing- and turned ‘show queries’ on to see what queries were generated. What I found was- if I put the wrong name in for the sites? It would just use the site I was currently on. In other words- I think if you set an invalid parameter it just ignores it and uses the current site instead.
Can try it yourself- create a blank test template, try my code and don’t change anything but the site parameter. Triple check that the site shortnames are correct. Then- turn ‘Show queries’ on in ‘Admin- System Prefs- Output and debug’. You can trace where it’s pulling in the related tag stuff:
26
SELECT t.tag_id, t.tag_name FROM exp_tag_entries te LEFT JOIN exp_tag_tags t ON t.tag_id = te.tag_id WHERE t.site_id IN ('1','2') AND te.entry_id = '188'
27
SELECT DISTINCT(te.entry_id) FROM exp_tag_entries te LEFT JOIN exp_tag_tags t ON t.tag_id = te.tag_id WHERE t.site_id IN ('1','2') AND te.type = 'weblog' AND te.entry_id != '188' AND ( t.tag_name = 'first tag' OR t.tag_name = 'blarg')
The relevant bit is t.site_id IN (1,2). To pull from multiple sites, you’ll need multiple ids showing there. Like I say- an invalid site shortname seemed to be ignored for me.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.