Apologies for what promises to be a long post.
To summarize as concisely as possible, the basic problem is to create a site-wide header template/snippet that dynamically sets the <title> and <meta> tags, while creating the minimum number of templates (e.g., using only index templates for as many template groups as possible, thus sharing a template for list-view and single-entry view). I need to conditionally get the information either from {exp:channel:entries} or {exp:channel:info}. The only method I’ve found so far to determine where the information must come from is to put the HTML tags inside an {exp:channel:entries} loop and count the results, which has unwanted effect of inserting the HTML tags multiple times. Preload replace variables would solve the entire problem except that they apparently can’t store EE data.
So that’s the summary. Here’s a bit more detail:
I’ve been using absolute_results as the criteria of {if} conditional statements to see if the template is loading a listing of entries or a single entry. The problem with this is at least twofold:
1.) It seems to require the HTML tags to be inside the {exp:channel:entries} loop, which inserts the tags
multiple times on pages showing multiple entries, and,
2.) It wouldn’t work in situations where {exp:channel:entries} only returns one item, yet context requires
displaying a listing-style page anyway (this may be only a hypothetical problem).
I could easily accomplish what I want if I were willing to create some additional templates. However, I have some channels which, with good use of {if} conditionals, could easily use only the index template to display both list view and single-entry view. It’s hard to justify cluttering my URLs with otherwise-meaningless segments just to load a different template. Besides which, extra templates are unnecessary complexity for development and maintenance, so I’d rather handle as much as possible through {if} conditionals within index templates.
So that’s the situation with as much clarity as I can describe it with. Any ideas appreciated, especially with regards to what other criteria I could use in my {if} conditionals that would more accurately determine if the template should be loading a list view or single-entry view.
Thanks,
Matthew