Hi, EE is clearly very powerfull but I am struggling to understand how you assign a weblog to a given template? If I have multiple weblogs with the same look and feel do I need to create a new template group through which to view each?
To create the association, you go into the template and find the weblog= tag and change it to be the weblog’s shortname. That creates the assocation. The default templates use assigned variables to change this, so that you can do this instead at the top of the template, rather than looking for all instances of weblog=.
To create the association, you go into the template and find the weblog= tag and change it to be the weblog’s shortname. That creates the assocation. The default templates use assigned variables to change this, so that you can do this instead at the top of the template, rather than looking for all instances of weblog=.
Hi Lisa,
I realize this is an old post, but I have a similar question that I posted on Friday and I still don’t seem to have the answer.
I know how to create the association and assign variables, but that still limits me to creating a different template for each weblog: I see over and over again in the forums that there doesn’t have to be a 1:1 relationship between weblogs and templates, but I still don’t see any other way.
In my case, let’s say I had two weblogs called ‘about’ and ‘services’, each with their own multiple categories and entries. Now, each of the entries of both weblogs displays identically: they’re all the same ‘secondary’ page layout, running off the same ‘default_site/info’ template. If I put weblog= in the entries display tag, I limit to a specific weblog, and then have to create a different template for each weblog. But if I don’t hard-code it, how does the template know which weblog to display? Do you see the problem?
Thanks for your prompt reply. Indeed yes I have read each of your articles as well as Derek’s “Behind the Curtain” series and everything I could find on Jambor-ee…
Which makes me feel all the more silly that I still must not understand something so basic; did my question make sense in the previous post? I explained in more detail in a post that Sue replied to, but I’m not sure she answered my question (or perhaps I didn’t explain it clearly!)
All that you do is use the weblog= parameter to *allow* the template to show information from those weblogs. You restrict what information is then shown by category, date, or single entry - or some other custom segment work, generally (which I haven’t covered in my series).
Thanks for your persistence… I hate to be a pest, but that’s still not quite what I’m looking for. I’ll try it again from the top, maybe I can be a little more clear.
I have two specific, related questions that I’m sure are quite simple but I’m having the darndest time wrapping my head around them…Here goes!
1. I understand how to use the weblog= parameter, but you can only choose one weblog, yes? I’d like to know how the same template can display information from multiple weblogs. Either:
a) I can hard-code a specific weblog using the parameter into a template, then that template will only display information from that weblog and no other. And that means I’ll have to create a different template for each weblog, which I’m trying to avoid and which others have explicitly stated is not necessary.
b) Or, I don’t specify any weblog in the weblog= parameter. If so, how does it know which template to allow to display?
Sue mentioned that a 1:1 relationship (that is, a template for every weblog) is not necessary, that you can pass information to the template parser via the URL, but it’s still not clear to me…
Here’s a little background to this first question: Let’s say I have several weblogs with several categories each. Now, each of the entries in these weblogs (let’s call them ‘about’ and ‘service’) all look the same—they all have the same layout, the same template. So it seems to me that the ‘about > our team > Jon Doe’ entry and the ‘services > marketing > email newsletter’ entry *should* be able to display using the same template. But if I write {...weblog=“about”} or {...weblog=“services”} into the tag, it won’t work, right?
So that’s the first question. The second is:
2. What is the relationship between the path of the weblog and the template used to display it? Let’s say that same ‘about’ weblog has a path of ‘domain.com/index.php/about’, which I specify in the ‘weblog management’ portion of the admin. But the URL of the template that displays it is ‘domain.com/index.php/default_site/info’ following the ‘index.php/template_group/template’ hierarchy… I’m not really sure what to ask here, I’m just not sure how to reconcile what appears to be two locations for the same thing.
Phew! I apologize for the novel, thanks in advance for any assistance.
Ok, you very much edited your post. My response still stands - most of this can be clarified by noting that you can pipe multiple weblogs into the weblog= parameter.
Aha, ok, an explanation of paths. I was thinking about writing on this in the blog but it’s covered really well in the path variables section of the documentation.
But to reconcile it - the paths are explained (let me know if you’re still flummoxed by them) - but if you leave off the “index” template and have just the template group, then EE assumes you meant the index of that template group.
Let’s see… but piping multiple weblogs doesn’t tell EE “hey, this template can be used for any of these weblogs” it means “hey, I want to display /all/ of these weblogs,” which is still not quite on the mark. Here’s my specific example again:
Here’s a little background to this first question: Let’s say I have several weblogs with several categories each. Now, each of the entries in these weblogs (let’s call them ‘about’ and ‘service’) all look the same—they all have the same layout, the same template. So it seems to me that the ‘about > our team > Jon Doe’ entry and the ‘services > marketing > email newsletter’ entry *should* be able to display using the same template. But if I write {...weblog=“about”} or {...weblog=“services”} into the tag, it won’t work, right?
Ok, you very much edited your post. My response still stands - most of this can be clarified by noting that you can pipe multiple weblogs into the weblog= parameter.
Please see my reply to this above…
Lisa Wess - 27 August 2007 02:24 PM
Aha, ok, an explanation of paths. I was thinking about writing on this in the blog but it’s covered really well in the path variables section of the documentation.
But to reconcile it - the paths are explained (let me know if you’re still flummoxed by them) - but if you leave off the “index” template and have just the template group, then EE assumes you meant the index of that template group.
Make sense?
It does and I understand that, but that’s still not what I’m asking. What is the purpose of setting the weblog path in the admin section if the URL is entirely generated by the template & template group? It doesn’t seem to have any purpose… please review my question above for more details.
Let’s see… but piping multiple weblogs doesn’t tell EE “hey, this template can be used for any of these weblogs” it means “hey, I want to display /all/ of these weblogs,” which is still not quite on the mark.
That depends on the type of template you’re visiting. If it’s a general purpose, multi-entry page, then it does say “display all of these weblogs”. =) The first article in the Semantics series should explain that. It is only by adding to the URL that you restrict what is viewed, but that restriction is in combination with the parameters in your weblog entries tag, including the weblog= parameter. If you visit a template with the weblog entries tag and a single-entry appended, unless the weblog is specified in the weblog= parameter, then that entry can not be shown in that template.
What is the purpose of setting the weblog path in the admin section if the URL is entirely generated by the template & template group?
Those allow you to use specific variables for particular tags, such as the {comment_url_title_auto_path} variable. This means you can set up one template accessing many weblogs, but where the single-entry page is a different template for one or all of those weblogs. It allows you to use a weblog specific variable rather than a series of conditionals.
All right, we’re getting closer, thanks! I think I’m getting it… you said:
There are several ways that you might visit a template that contains this code, and the URL that you visit it at is what will define what information is displayed. For this post, we’ll concentrate on the difference between a ”single-entry page” and a ”multi-entry page”
Single vs multi-entry, dependent on the URL, got it. So does it follow then that if, according to your example, instead of
{weblog="default_site"}
I could pipe the parameter and put
{weblog="default_site|about|services"}
etc., on and on with the different weblogs I want to display using that template? And that, depending on segment 3, the template will know to display one of the weblogs over another because it can associate a given URL title with its proper weblog? If so, then that does indeed answer an important part of my question! Thanks very much.
The only part missing, then, is how picky I want to be with the URL itself: I don’t want an entry in the ‘about’ blog to be visible at ‘index.php/default_site/url_title’, I want it to be ‘index.php/about/url_title’ or ‘index.php/services/url_title’ and so on with each weblog, for intuitive navigation and SEO purposes, etc.
So, here’s the heart of the matter—is that possible? I think not, unless there’s some fancy URL remapping going on (or maybe not?). But because the template group *defines* the URL, for every *specific* URL I want to have, I *must* have a template group with the same name, or it won’t work. Is this correct? Because I want to dictate a specific URL for a given entry, I must create a template group for it? (A simple yes/no to this would suffice, that’s an acceptable resolution to me.)
Continuing…
Those allow you to use specific variables for particular tags, such as the {comment_url_title_auto_path} variable. This means you can set up one template accessing many weblogs, but where the single-entry page is a different template for one or all of those weblogs. It allows you to use a weblog specific variable rather than a series of conditionals.
OK, this is the first bit I don’t fully understand, but that just means I need more practice! “One template accessing many weblogs”? That’s what I’m looking for! Let me dig around in the docs a bit…
You are correct in that if you never want entries from a particular weblog showing in some template, you should leave that shortname out of your weblog= parameter. Or use the not argument, explained in the docs.
Just to clarify this:
And that, depending on segment 3, the template will know to display one of the weblogs over another because it can associate a given URL title with its proper weblog?
segment_3 does not show a particular weblog at all, it shows a particular permalink (by url_title or entry_id), category (by category_id, or segment_4 for category_url_titles), or date (in the long sequence as explained in my series). It is limited by the parameters in the weblog entries tag(s) on that page, however. So if you have an entry “raining_cats_and_dogs” in a weblog with the shortname “animals” - but have only weblog=“default_site” - then appending that url_title will get you nowhere.
I realize, it was just for brevity’s sake, thanks!
You are correct in that if you never want entries from a particular weblog showing in some template, you should leave that shortname out of your weblog= parameter. Or use the not argument, explained in the docs. ...
segment_3 does not show a particular weblog at all, it shows a particular permalink (by url_title or entry_id), category (by category_id, or segment_4 for category_url_titles), or date (in the long sequence as explained in my series). It is limited by the parameters in the weblog entries tag(s) on that page, however. So if you have an entry “raining_cats_and_dogs” in a weblog with the shortname “animals” - but have only weblog=“default_site” - then appending that url_title will get you nowhere.
Right, but if I *do* have that weblog’s short name in the parameter, the url_title will work, correct? So in my case let’s say there are three weblogs, and I include all three short names in the parameter of the template’s entries tag, then any url_title that appears in segment 3 and is in one of those three weblogs will appear as a single entry…
And, finally, using the ‘Pages’ module lets me remap URLs, but otherwise I have to create a corresponding template group in order for the URL to display exactly the way I want. If that’s right, I think I finally get it!
Make sense?
It does, hallelujah! I’m definitely going to write this up as part of the case study… our design firm has totally revamped our company site and we’re using EE to power it, that’s what all this is about. Thanks again!
then any url_title that appears in segment 3 and is in one of those three weblogs will appear as a single entry…
Yes =)
And, finally, using the ‘Pages’ module lets me remap URLs, but otherwise I have to create a corresponding template group in order for the URL to display exactly the way I want. If that’s right, I think I finally get it!
Well, depending on how you want things setup - but yes, if you want that info in segment_1, then a new template group. The Pages module overcomes this and does a beautiful job of it. =)
Thanks, mac. Out of curiosity, what was the missing link insofar as my articles went? Those were meant to address this kind of question, though I didn’t discuss how it knows what the weblogs are. Was that the sticking point?