x
 
Create New Page
 View Previous Changes    ( Last updated by Mark Bowen )

Using the entry id output from a weblog tag in another weblog tag

Many people on the forums ask how you can have one weblog tag on a page and once it has output the data you are fetching, use the entry_id(s) inside another weblog tag on the same page.

The easiest way to do this is to use an embedded template otherwise you will find yourself running into template parsing issues.

One way to do this sort of thing is shown here below although I would highly recommend seeing if you can either write a SQL query to do the same sort of thing or you could perhaps use some PHP to get at what you need to. The code below is however one way to do this sort of thing, just be careful to make sure you use a good sprinkling of the dynamic=”“ parameter on your weblog tags so that you don’t use up too many resources.

Main Template

{exp:weblog:entries weblog="some_weblog" limit="1"}

{related_entries id
="some_field"}
{emb
*d="embedded-template" entry_id_for_embed="{entry_id}"}
{
/related_entries}

{
/exp:weblog:entries} 

N.B. - Replace the * above with an ‘e’ to make the word embed. The WIKI won’t allow me to place that word in

Embedded Template embedded-template

{exp:weblog:entries weblog="default_site" entry_id="{embed:entry_id_for_embed}" dynamic="off"}
<h2>{title}</h2>
{/exp:weblog:entries} 

Make sure that you have liberal usage of the disable=”“ parameter on both weblog tags just to ensure there isn’t massive overhead. I wouldn’t expect there to be in this case but there could be so definitely something to just watch out for.

More information on embedded templates can be found here.

Author - Mark Bowen

Category:EE1

Categories: