0

What is the propper way to use NSM better meta and layouts?

At the moment, my layout has the NSM tag in the head, I've wrapped some channel entry tags around it. Not sure if this is the correct way to use it?

{exp:channel:entries require_entry="yes" limit="1" dynamic="yes"}
{exp:nsm_better_meta:template entry_id="{entry_id}"}
{/exp:channel:entries}

I also have another problem, how do I deal with the homepage? I can't seem to pull any nsm data through.

The homepage entry_id is 1, with a status of hidden.

When I was using embeds I used...

{embed="/includes/head" title_prefix="Site" hide_site_title="y" entry_id="1"}

But with layouts I can't use those parameters.

1 Answer 1

0

Set a layout variable for the entry_id, then instruct NSM Better Meta to use that if it exists.

In your entry template:

{layout:set name="entry_id" value="{entry_id}"}

(This would have to be within a channel:entries loop obviously.)

Then in your layout template:

{exp:nsm_better_meta:template{if layout:entry_id} entry_id="{layout:entry_id}"{/if}}
3
  • Hi Derek, that's great, that's the conclusion I've come to now, but I wasn't sure if it was correct. I do have a problem though, is that it means me having to explicity set the layout variable in every template, which means for whatever reason If I had a re-jig I'd have to physically change it in every template, is there a way around this, an alternative etc? Commented May 11, 2016 at 14:47
  • I have to put a space after {exp:nsm_better_meta:template (the word template) otherwise I get an error. Commented May 11, 2016 at 15:34
  • NSM Better Meta needs to know which entry to pull content from somehow, so any solution will involve specifying the entry ID somewhere (be it in a layout variable, an embed variable, or otherwise). Commented May 11, 2016 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.