-
-
Save bjornbjorn/4039233 to your computer and use it in GitHub Desktop.
// 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}"/> |
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.
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?
@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
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
How can I get SEO Lite to work with categories landing pages to have title/keywords/descriptions based on each category?
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',
)
),
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?
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.
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.
Hi Bjorn, where do I have to put the config.local.php file? Thanks
@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.
Can you use this plugin on EE version 2.6.1?
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: