Hi. I have some entries that use the Pages Module to retain their old .html-based URL structure.
For example, the template/entry http://site.com/main/entry becomes http://site.com/main/entry.html through use of the Pages Module.
I want to be able to use LG Better Meta on these pages, but can’t figure out the syntax. I can use the following tag to show the page before the Pages Module puts its stamp on it, but that’s not the link people are going to be calling as it isn’t referenced in the site anywhere.
{exp:lg_better_meta_pl:template url_title="{segment_2}"}When the URL is http://site.com/main/entry, I get the results of the LG Better Meta plugin doing its magic. When the URL is http://site.com/main/entry.html, I do not.
Can anyone help me figure out how to resolve this?
Hi Marcus,
That’s an interesting problem. I would recommend using a weblog:entries tag to grab the entry_id and pass that to the extension directly. If you have caching turned on and disable all of the params it will be a pretty light weight call.
I personally wrap the main portion of a single entry page in single weblog:entries tag. The page will break if the entry is not found becuase the header won’t be included. This isn’t really a concern when you use require_entry = “yes” and {if no_results}. I’ve added an example below of a fairly simple and standard blog post.
You’ll also notice that I’m setting the “meta_title_suffix” param which adds a little more SEO to the title.
{assign_variable:this_page_weblog="blog"}
{exp:weblog:entries
cache="yes"
disable="category_fields|member_data|pagination|trackbacks"
dynamic="off"
limit="1"
refresh="10"
require_entry="yes"
rdf="off"
status="not closed|Pending"
weblog="{this_page_weblog}"
url_title="{segment_3}"
}
{if no_results || segment_2 != "post"}{redirect="404"}{/if}
{embed="_includes/.head"
entry_id="{entry_id}"
meta_title_suffix="{blog_title}"
}
<div id="content">
<div class="copy">
<h1 class="page-title">{title}</h1>
{entry_date format="%d:%m:%Y"} |
{categories}<a href="/blog/category-archive/#cat-{category_url_title}">{category_name}</a> + {/categories}
{blog_body}
</div>
</div>
{embed="_includes/.foot"}
{/exp:weblog:entries}A quick follow up. If you need to include other {exp:weblog:entries} tags on the page you can unbalance the first {exp:weblog:entries} tag like so:
cache="yes"
disable="category_fields|member_data|pagination|trackbacks"
dynamic="off"
limit="1"
refresh="10"
require_entry="yes"
rdf="off"
status="not closed|Pending"
weblog="{this_page_weblog}"
url_title="{segment_3}"
}
{if no_results || segment_2 != "post"}{redirect="404"}{/if}
{embed="_includes/.head"
entry_id="{entry_id}"
meta_title_suffix="{blog_title}"
}
<div id="content">
<div class="copy">
<h1 class="page-title">{title}</h1>
{entry_date format="%d:%m:%Y"} |
{categories}<a href="/blog/category-archive/#cat-{category_url_title}">{category_name}</a> + {/categories}
{blog_body}
</div>
</div>
{/exp:weblog:entries}
<ol>
{exp:weblog:entries weblog='some_other_blog' dynamic='off'}
<li>{title}</li>
{/exp:weblog:entries}
</ol?>
{embed="_includes/.foot"}</code></pre>
Again you’re guaranteeing an entry so the unbalanced tags don’t really matter.
checkout the section on embedding headers in the howto section: http://leevigraham.com/cms-customisation/expressionengine/lg-better-meta/
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.