ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

One template, several weblogs?

May 30, 2008 5:24am

Subscribe [5]
  • #1 / May 30, 2008 5:24am

    Tomaz

    9 posts

    I have followed Boyink’s tutorial on website building, and he uses one template per weblog approach. I have a similar project, but with 30 weblogs, and i don’t want to make that many templates because i think one would be enough. Can it be done, and how?

  • #2 / May 30, 2008 5:39am

    Sean C. Smith

    3818 posts

    as long as you don’t mind all the blogs looking the same - I would considering doing this.

    You could make your one master template and then for each of the blogs create a new template and select the option to duplicate a current template. After you’ve duplicated it, then go into the new template and change your master_weblog variable and you’ll be set.

    I’m sure there’s a better way and maybe someone will post it, but this is what I came up with off the top of my head.

  • #3 / May 30, 2008 6:26am

    Yvonne Martinsson

    204 posts

    If your weblogs have the same field group and you want to display them together you could just add each weblog to the weblog=”” parameter.

    {exp.weblog:entries weblog="weblog_1|weblog_2|weblog_3"}

    If you have different field groups or different design, you’d have to split it up. But you’d definitely not need 30 template groups. Think about how you want to display the weblogs and then make a template for each display. Add parameters, trim the code and, most of all, see the docs for more advanced solutions. You’ll need them!

  • #4 / May 30, 2008 7:30am

    Tomaz

    9 posts

    I think you misunderstood me, i’m asking if only one template can be used for many weblogs with different field groups.

  • #5 / May 30, 2008 7:39am

    Ingmar

    29245 posts

    Why not? You’d probably need a few conditionals based upon {weblog_id} or {weblog_shortname}, but I don’t think that’s going to be much of a problem.

  • #6 / May 30, 2008 7:59am

    Yvonne Martinsson

    204 posts

    No, I didn’t really misunderstand you, but I tried to keep it as simple as possible. As Ingmar says, you can mix in whatever way you want, but it takes some knowledge of conditionals and the use of embeds would simplify as well. It’s like weaving a tapestry together. Get me?

  • #7 / May 30, 2008 9:32am

    carvingCode

    380 posts

    >>
    Why not? You’d probably need a few conditionals based upon {weblog_id} or {weblog_shortname}, but I don’t think that’s going to be much of a problem.
    <<

    Could you give examples of conditionals using {weblog_id} and {weblog_short_name}?  TIA

  • #8 / May 30, 2008 9:41am

    Ingmar

    29245 posts

    Well, obviously much will depend on your setup, but something like this could get you started:

    {exp:weblog:entries weblog="foo|bar"}
     {title}
    
     {if weblog_short_name="foo"}
      {!-- Foo custom fields --}
     {/if}
    
     {if weblog_short_name="bar"}
      {!-- Bar custom fields --}
     {/if}
    {/exp:weblog:entries}

    Well, something like that, anyway.

  • #9 / May 30, 2008 9:53am

    carvingCode

    380 posts

    Thanks.  This is a much better way of handling this than I used.  I’ll have to adjust the template.

  • #10 / May 30, 2008 10:45am

    Ingmar

    29245 posts

    Just be aware that it will mix elements of both weblogs: An entry comes up, and the appropriate fields get displayed, then the next one etc. If you want to separare the two weblogs, you’ll probably need two exp:weblog tags.

  • #11 / May 30, 2008 12:58pm

    carvingCode

    380 posts

    Can’t this be structured with an {if:elseif}?  Then only 1 weblog’s field are pulled in on that run through the loop?

  • #12 / May 30, 2008 1:16pm

    Ingmar

    29245 posts

    You could use advanced conditionals, but that wouldn’t change much. Since you only have one exp:weblog:entries tag, every entry gets pulled, and then it’s the good into the pot, the bad into the crop, as it were. This might be perfectly OK, I have used it often myself, just something that you need to be aware of.

  • #13 / May 30, 2008 1:18pm

    Yvonne Martinsson

    204 posts

    No, it will work in the same way as Ingmar’s example above. But, if you only want to display one or a select choice of weblogs at the time, you can work with embeds and url_segements.

    Let’s say you add weblog_short_name “about” to your URL. Then you can pass it to an embed. First you have to create a new template, for instance “content” where you have the exp:weblog:entries tag, custom fields and whatever you want to show. But, you leave the weblog parameter open for an embed variable.

    In the main template you write (you can use any word for section here or use any segment):

    {if segment_1=="about"} {embed={my_template_group}content section="about"} {if:else} other conditionals{/if}

    In the embed you add to the parameter weblog in the weblog:entries tag the following:

    weblog="{embed:about}"

    You craft what is displayed, never forget that!

  • #14 / May 30, 2008 4:58pm

    carvingCode

    380 posts

    >>
    Since you only have one exp:weblog:entries tag, every entry gets pulled, and then it’s the good into the pot, the bad into the crop, as it were.
    <<

    I see.  Wonder if this would be considered for a feature request?

    FR: “The ability to intermingle (technical term) different “weblog” content, each with its own custom field group, into one date sorted listing.”

    [rb]

  • #15 / May 30, 2008 5:03pm

    Ingmar

    29245 posts

    Unless I completely misunderstood you, this is exactly how it works: pulling entries from both weblogs, sorting them in one listing. Just try it out for yourself, see if it fits your needs.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases