0

I almost have what I am after working completely thanks to the answer from @bjørn-børresen on this previous question.

Now I have the description and images working the way I need, but I cannot get the title replacement to operate like I am needing.

Using the documentation, I entered the config options as:

/**
 *
 * Pull additional info for SEO Lite
 *
 * channel_id => array(field_id => tag_name)
 **/
$config['seolite_extra'] = array(
    '13' => array(                               // mission
        'headline' => array(
            'field_id' => 38,                    // {intro_title}
            'field_type' => 'text',
        ),
        'desc' => array(
            'field_id' => 37,                    // {brief_intro}
            'field_type' => 'editor',
        ),
        'image' => array(
            'field_id' => 36,                    // {page_header}
            'field_type' => 'file',
        )
    )
);

So inside my SEO template, (simplified here of course), I have the variable {extra:headline}in my template, but it doesn't seem to be reading. I am including the switchee logic to check for a default text string inside the default value entered and using the chopper plugin to trim the characters and strip html.

<title>{extra:headline} | {site_name}</title>
<meta name="keywords" content="{meta_keywords}" />
{exp:switchee variable="{meta_description}" parse="inward" }
    {case value="/\\\\My default string/"}
        <meta name="description" content="{exp:chopper chars='157' append='...'}{extra:desc}{/exp:chopper}"/>
        <meta property="og:description" content="{exp:chopper chars='157' append='...'}{extra:desc}{/exp:chopper}"/>
    {/case}
    {case default="Yes")
        <meta name="description" content="{exp:chopper chars='157' append='...'}{meta_description}{/exp:chopper}" />
        <meta property="og:description" content="{exp:chopper chars='157' append='...'}{meta_description}{/exp:chopper}"/>
    {/case}
{/exp:switchee}

The only issue I am having is getting the {extra:headline} to output.

EE 3.1.4, Stash 3.0.0, SEO Lite 1.5.1

0

As far as I can tell {extra:headline} should output fine, I would check:

  1. That the channel_id is correct. If you have multiple channels you would need to add this config for each channel (specifying which fields to pull data from for each channel)

  2. That the field_id's are correct. Note; SEO Lite for EE3 only supports type 'text' or 'file'. So even if you're pulling from an 'editor' field you'll have to specify 'text' (as the type of content pulled from exp_channel_data is text).

And lastly, inspecting the code I see it supports "max_length" which is not specified in the docs, I'll fix that. But that means you should probably not need to use chopper (and switchee?).

Something like this in your config:

'desc' => array(
        'field_id' => 37,                    // {brief_intro}
        'field_type' => 'text',
        'max_length' => 157,
    ),

I realise that {extra:headline} was the main issue here, but again, I don't see why that shouldn't be output so please doublecheck the database id's you've used. (what is output for it btw, the actual tag ({extra:headline}) or just empty?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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