1

I'm using MSM to manage a number of sites, but on one of them I need to list ALL news items across ALL sites (which is easy!) ... however I need to identify which site each item has come from by either site_id or site_short_name, etc.

So... I'm looking for:

{exp:channel:entries channel="news" site="siteA|siteB|siteC"} 
{count}. {title} - {site_short_name}<br />
{/exp:channel:entries}

To result in:

1. My great title - siteB<br />
2. Another great title - siteA<br />
3. Yet another great title - siteC<br />

Unfortunately, the {site_short_name} is only coming back with the site_short_name of the site I am actually on. For example if the above code is on Site A, it comes back with the results:

1. My great title - siteA<br />
2. Another great title - siteA<br />
3. Yet another great title - siteA<br />

Anyone able to help?

Cheers.

1

I think, it would be better to create to global variables within the index.php files of each site. In the index.php of each site you can have the code like:

$assign_to_config['global_vars'] = array('site_1_short_name' => '[short name of site 1]',  'site_2_short_name' => '[short name of site 2]');

Please note: You need to put this global variables assignments array above the last line of code i.e above the line of code:

require_once BASEPATH.'core/CodeIgniter'.EXT;

within index.php

The global variables {site_1_short_name} and {site_2_short_name} can be used anywhere within the templates.

Updated:

I don't think above would work.

The small SQL can be used with Query module:

{exp:query sql="SELECT exp_sites.site_name AS SiteShortName FROM exp_sites, exp_channel_titles
WHERE exp_sites.site_id=exp_channel_titles.site_id AND exp_channel_titles.entry_id='{entry_id}'"}

{SiteShortName}

{/exp:query}
4
  • Doesn't help, though, because he's pulling in stuff from multiple sites in the same channel:entries loop.
    – adrienne
    Apr 18 '13 at 6:35
  • Thanks for the answer Bhashkar ... but adrienne is right. I need to know which site the ENTRY is from. Once I'm on a site, I can get the site_short_name already. Apr 18 '13 at 6:36
  • Yes, I just realize that it wouldn't work. I think, if you can use sql with the query module it can output right output for site_short_name. I put this query in my answer. Apr 18 '13 at 6:54
  • Ah! Nice. That works perfectly. There won't actually be so many items on each page that the extra few Query calls will make any difference. Thanks! Apr 18 '13 at 7:25
1

Try to use {entry_site_id}

http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#entry-site-id

And this Query module:

{exp:query sql="SELECT site_name FROM exp_sites WHERE site_id='{entry_site_id}'"}
    {site_name}
{/exp:query}

This add-on can help too: Blog Info

http://devot-ee.com/add-ons/blog-info

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.