Low Variables and NSM Better Meta - can they play nice together?
Hey,
So, after your release of 2.3, I'm finally giving LV a shot. My first bump in the road is getting NSM Better Meta to work with LV.
I usually embed the header which embeds the nsm tag wrapped in a channel entries tag to keep the results dynamic. It works beautifully.
I have a similar set up using LV, but I know I'm missing something due to parse orders. Here's what I'm trying:
{lv_header} contains {exp:low_variables:single var="lv_seo_meta"}
{lv_seo_meta} has {exp:channel:entries limit="1" disable="pagination|member_data|categories"}{exp:nsm_better_meta:template entry_id="{entry_id}"}{/exp:channel:entries}
This is throwing me PHP errors.
channel/mod.channel.php
- Undefined index: 2
- Invalid argument supplied for foreach()
Bottom line, I'm interested to hear if you know any better ways to get NSM Better Meta and LV to play nicely. Thanks!
Replies
Low 17 Oct 2012 15:09
Hi Stephen,
The error is thrown by the Channel module, which seems to indicate that the issue might not be LV related per se. Do you see a line number for that error?
Also, I take it the lv_header variable has early parsing enabled? Is the content of the lv_seo_meta variable working okay if you just enter it into the template as is?
Stephen Callender 17 Oct 2012 15:23
Hello,
Thanks for the fast response. I tested the variable on its own and it worked. That made me rethink how I was doing this and I found an acceptable solution.
I split the {lv_header} into two and pulled out the {lv_seo_meta}.
So in all my page templates, I now have:
{lv_head_open}
{lv_seo_meta}
{lv_head_close}
The lv_seo_meta has
{exp:channel:entries channel="my-channel" limit="1"}{exp:nsm_better_meta:template entry_id="{entry_id}"}{/exp:channel:entries}
All the low variables are parsing early and it works.
Would you suggest any other way? Or does this look good to you?
Low 17 Oct 2012 15:35
I think your first approach should actually work (however, I haven't actually used better meta), so we could try to debug that, if you want. If so, here's a couple of questions:
Is early parsing enabled for the {lv_header} variable?
What was the exact error message?
What's your EE version?
Stephen Callender 17 Oct 2012 15:47
No, I wouldn't worry about it. I was over-thinking it.
I just reduced the code to one variable now and this works. I don't need the Better Meta tag in a separate variable, which is even better.
{lv_head} has
<!DOCTYPE html>
<html>
<head>
<meta stuff>
{exp:channel:entries channel="pages" limit="1"}{exp:nsm_better_meta:template entry_id="{entry_id}"}{/exp:channel:entries}
<link rel="stylesheet" type="text/css" href="/assets/css/style.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
</head>
<body>
Low 17 Oct 2012 15:50
Okay, perfect. Just let me know if you need more help.
Stephen Callender 17 Oct 2012 15:54
Thanks. I appreciate it.