Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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}"/>
@gabric098

This comment has been minimized.

Copy link

@gabric098 gabric098 commented Jun 2, 2013

Hi Bjorn,
thank you so much for supporting this fantastic plugin.
I'm looking to the code above and it seems me pretty cool to be able to pull data from cusom defined fields using the extra: sintax.
My question is: is it possible to pull data from the standard entry fields? (e.g. author) And, if it's possible which is the right sintax to use? I've tried something like this but it doesn't work:

<title>{title}</title>
<meta name='keywords' content='{meta_keywords}' />
<meta name='description' content='{meta_description}' />
<meta name='author' content='{entry_author}' />
<link rel='canonical' href='{canonical_url}' />
@bjornbjorn

This comment has been minimized.

Copy link
Owner Author

@bjornbjorn bjornbjorn commented Oct 21, 2013

Hi gabric, sorry I havent' seen your message before now (guess gists comments don't send notifications, either that or it slipped through) ..

Anyway, to answer your question - no, currently only custom fields of type text, file & assets are supported. So you can't get the entry author at this point.

@neilbradley

This comment has been minimized.

Copy link

@neilbradley neilbradley commented Jul 9, 2014

Hi Bjorn,
Is there a way to do conditionals here. So for example, if the {meta_description} is not complete, then fall back to an {extra:desc} field?

The reason I ask is that we have a site with hundreds of entries that have short descriptions, so I would like to fallback to these instead of site default if possible?

@bjornbjorn

This comment has been minimized.

Copy link
Owner Author

@bjornbjorn bjornbjorn commented Aug 12, 2014

@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

This comment has been minimized.

Copy link

@bmackler bmackler commented Sep 21, 2014

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

This comment has been minimized.

Copy link

@InteractM InteractM commented Oct 1, 2014

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

@bjornbjorn

This comment has been minimized.

Copy link
Owner Author

@bjornbjorn bjornbjorn commented Oct 7, 2014

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

This comment has been minimized.

Copy link

@goodmixer goodmixer commented Dec 15, 2014

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

This comment has been minimized.

Copy link
Owner Author

@bjornbjorn bjornbjorn commented Dec 15, 2014

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

This comment has been minimized.

Copy link

@goodmixer goodmixer commented Dec 15, 2014

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

This comment has been minimized.

Copy link

@giacomocarra giacomocarra commented Dec 22, 2014

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

@1stevengrant

This comment has been minimized.

Copy link

@1stevengrant 1stevengrant commented Nov 12, 2015

@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

This comment has been minimized.

Copy link

@milliephanillie milliephanillie commented May 26, 2016

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