Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bjornbjorn/4039233 to your computer and use it in GitHub Desktop.
Save bjornbjorn/4039233 to your computer and use it in GitHub Desktop.
SEO Lite pulling in additional fields
// from config.local.php (FocusLab's config)
/**
*
* Pull additional info for SEO Lite
*
* channel_id => array(field_id => tag_name)
**/
$env_config['seolite_extra'] = array(
'1' => array( // news
'desc' => array(
'field_id' => 3,
'field_type' => 'text',
),
'image' => array(
'field_id' => 45,
'field_type' => 'file',
)
),
'4' => array( // blog
'desc' => array(
'field_id' => 18,
'field_type' => 'text',
),
'image' => array(
'field_id' => 46,
'field_type' => 'file',
)
),
'5' => array( // portfolio
'desc' => array(
'field_id' => 29,
'field_type' => 'text',
),
'image' => array(
'field_id' => 43,
'field_type' => 'assets', // Assets fieldtype, will pick the first image if multiple can be selected
)
)
);
<title>{title}{site_name}</title>
<meta name='keywords' content='{meta_keywords}' />
<meta name='description' content='{meta_description}' />
<link rel='canonical' href='{canonical_url}' />
<meta property="og:url" content="{canonical_url}"/>
<meta property="og:title" content="{entry_title}"/>
<meta property="og:description" content="{extra:desc}"/>
<meta property="og:image" content="{extra:image}"/>
@bjornbjorn
Copy link
Author

@nielbradley - yes, you can use conditionals like this:

{if '{extra:image}' != ''}
<meta property="og:image" content="{extra:image}"/>
{if:else}
<meta property="og:image" content="{site_url}static/img/lyse-logo.png"/>
{/if}

General note to anyone that might have questions about the functionality described in this gist - please ping me on Twitter after asking so that I may get back to you in a timely manner; https://twitter.com/bjornbjorn

@bmackler
Copy link

just found this add on , solves 95% of a major problem I was having with EE. Question though - How do I pull the title tag in to use for facebook og ?

This is the what I have in my templates, right before the -

{exp:seo_lite use_last_segment="y"
title_postfix='{embed:title_postfix}'
default_title='{embed:default_title}'
default_keywords='{embed:default_keywords}'
default_description='{embed:default_description}'
}

also do you have a suggestion for forcing the dynamic image for that posting?

thanks in advance

@InteractM
Copy link

How can I get SEO Lite to work with categories landing pages to have title/keywords/descriptions based on each category?

@bjornbjorn
Copy link
Author

Added support for photo_frame in extra_fields;

        '10' => array(                               // news EN
            'desc' => array(
                'field_id' => 3,
                'field_type' => 'text',
            ),
            'image' => array(
                'field_id' => 77,                    // Large top image
                'field_type' => 'photo_frame',
            )
        ),

@goodmixer
Copy link

Bjorn,
Should the
<meta property="og:image" content="{extra:image}"/>
be pulling in the full image path as I'm just getting the file name pulled in.
<meta property="og:image" content="puntillitas.JPG”/>
This causes facebook to give a og:image error when 'liked'.

This might be associated with also using ce:image which is renaming the associated image

/images/made/images/menu/puntillitas_450_450.JPG
Is there any way of getting the full image path into the og:image field?

@bjornbjorn
Copy link
Author

Hi, CE Img is just a fronend tag AFAIK and shouldn't affect the info given by the field, which Field are you using for the image? Also, make sure you're on the latest SEO Lite.

@goodmixer
Copy link

Updating from seo lite 1.4.7 to 1.4.9.3 fixed the issue with the full path to the image.
Was using assets file type if this is of help to anyone else.
Thanks Bjorn.

@giacomocarra
Copy link

Hi Bjorn, where do I have to put the config.local.php file? Thanks

@1stevengrant
Copy link

@bjornbjorn going over old ground here perhaps but I'm seeing the same thing attempting to pull through the full path to an Assets image where it just pulls out image.jpg as an example.

This makes sense though because field_id_x assigned in the config only has image.jpg as the example. I guess I could update the path within the template and restrict the upload directory but would be cool to be able to pull from where ever I want.

@milliephanillie
Copy link

Can you use this plugin on EE version 2.6.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment