SEO Metatag Info - fine plugin with extensive functions
Re: SEO Metatag Info - fine plugin with extensive functions
Happy to see the community working together - thanks to both of you! 
Re: SEO Metatag Info - fine plugin with extensive functions
Is it possible using a variable of the Plugin in the template, e.g. using $seo_desc as introduction for a post?
- fraenkiman
- Posts: 470
- Joined: Thu Feb 03, 2022 7:25 pm
- Location: Berlin, Germany
- Contact:
Re: SEO Metatag Info - fine plugin with extensive functions
Hello Wolfgang,
Out of the box, no. With a small hook, yes. The SEO plugin value is not assigned in Smarty. You could insert this function at the end of the plugin.seometataginfo.php file:
Then edit the entry-default.tpl file and insert
.
The result looks something like this: Best regards,
Frank
Out of the box, no. With a small hook, yes. The SEO plugin value is not assigned in Smarty. You could insert this function at the end of the plugin.seometataginfo.php file:
Code: Select all
/**
* Make per-entry SEO meta available to Smarty templates.
* Memorization reduces double reads within a request.
* Exposes: $seo_desc, $seo_keywords for the current entry block.
* For output in the template, e.g. in entry-default.tpl:
* {if $seo_desc}<i>{$seo_desc|escape}</i>{/if}
* {if $seo_keywords}<i>{$seo_keywords|escape}</i>{/if}
*/
function seometataginfo_assign_entry_vars($id) {
if (!is_string($id) || $id === '') return;
static $memo = array();
if (isset($memo [$id])) {
if (isset($GLOBALS ['smarty']) && is_object($GLOBALS ['smarty']) && method_exists($GLOBALS ['smarty'], 'assign')) {
$GLOBALS ['smarty']->assign('seo_desc', $memo [$id] [0]);
$GLOBALS ['smarty']->assign('seo_keywords', $memo [$id] [1]);
}
return;
}
$file_meta = SEOMETA_ENTRY_DIR . $id . '_metatags.ini';
// Ensure $smarty is usable
if (!isset($GLOBALS ['smarty']) || !is_object($GLOBALS ['smarty']) || !method_exists($GLOBALS ['smarty'], 'assign')) {
return;
}
$smarty = $GLOBALS ['smarty'];
if (!is_readable($file_meta)) {
$memo [$id] = array('', '');
$smarty->assign('seo_desc', '');
$smarty->assign('seo_keywords', '');
return;
}
$cfg = new iniParser($file_meta);
$descRaw = $cfg->get('meta', 'description');
$keysRaw = $cfg->get('meta', 'keywords');
$seo_desc = $descRaw !== false ? wp_specialchars(trim((string)$descRaw)) : '';
$seo_keywords = $keysRaw !== false ? wp_specialchars(trim((string)$keysRaw)) : '';
$memo [$id] = array($seo_desc, $seo_keywords);
$smarty->assign('seo_desc', $seo_desc);
$smarty->assign('seo_keywords', $seo_keywords);
}
// Bind during entry rendering so {$seo_desc} and {$seo_keywords} is available inside {entry} blocks
add_action('entry_block', 'seometataginfo_assign_entry_vars', 0);
Code: Select all
{if $seo_desc}<i>{$seo_desc|escape}</i>{/if}The result looks something like this: Best regards,
Frank
My
Re: SEO Metatag Info - fine plugin with extensive functions
Hello Frank,
Thank you. I tried your solution but it's not working on my test environment. The following lines were added to the errorlog file:
[Mon Sep 01 18:27:36.406959 2025] [php:warn] [pid 4888] [client 127.0.0.1:39734] PHP Warning: Undefined array key "seo_desc" in /opt/lampp/htdocs/fp-content/compile/e93fccb09cf8b04111b9595da102f3f4^11ce5b354f64090b7f9eaa526de967b8bbcc8f6b_0.file.entry-default.tpl.php on line 46, referer: http://localhost/
[Mon Sep 01 18:27:36.406993 2025] [php:warn] [pid 4888] [client 127.0.0.1:39734] PHP Warning: Attempt to read property "value" on null in /opt/lampp/htdocs/fp-content/compile/e93fccb09cf8b04111b9595da102f3f4^11ce5b354f64090b7f9eaa526de967b8bbcc8f6b_0.file.entry-default.tpl.php on line 46, referer: http://localhost/
PHP version is 8.2.12
Thank you. I tried your solution but it's not working on my test environment. The following lines were added to the errorlog file:
[Mon Sep 01 18:27:36.406959 2025] [php:warn] [pid 4888] [client 127.0.0.1:39734] PHP Warning: Undefined array key "seo_desc" in /opt/lampp/htdocs/fp-content/compile/e93fccb09cf8b04111b9595da102f3f4^11ce5b354f64090b7f9eaa526de967b8bbcc8f6b_0.file.entry-default.tpl.php on line 46, referer: http://localhost/
[Mon Sep 01 18:27:36.406993 2025] [php:warn] [pid 4888] [client 127.0.0.1:39734] PHP Warning: Attempt to read property "value" on null in /opt/lampp/htdocs/fp-content/compile/e93fccb09cf8b04111b9595da102f3f4^11ce5b354f64090b7f9eaa526de967b8bbcc8f6b_0.file.entry-default.tpl.php on line 46, referer: http://localhost/
PHP version is 8.2.12
- fraenkiman
- Posts: 470
- Joined: Thu Feb 03, 2022 7:25 pm
- Location: Berlin, Germany
- Contact:
Re: SEO Metatag Info - fine plugin with extensive functions
Good evening Wolfgang,
I can't reproduce the error. You may have forgotten to clear the theme and template cache.
Feel free to download the plugin from FlatPress 1.5.dev and try it out. I had no entries in the PHP log under PHP 8.4.
Best regards,
Frank
I can't reproduce the error. You may have forgotten to clear the theme and template cache.
Feel free to download the plugin from FlatPress 1.5.dev and try it out. I had no entries in the PHP log under PHP 8.4.
Best regards,
Frank
My
- fraenkiman
- Posts: 470
- Joined: Thu Feb 03, 2022 7:25 pm
- Location: Berlin, Germany
- Contact:
Re: SEO Metatag Info - fine plugin with extensive functions
For safety's sake, here is the modified entry-default.tpl file for the leggero theme.
My
Re: SEO Metatag Info - fine plugin with extensive functions
Hello Frank,
Thank you, but even a new installation didn't make it better. I will try again on the weekend with the Flatpress version on Github.
Regards
Wolfgang
Thank you, but even a new installation didn't make it better. I will try again on the weekend with the Flatpress version on Github.
Regards
Wolfgang
- fraenkiman
- Posts: 470
- Joined: Thu Feb 03, 2022 7:25 pm
- Location: Berlin, Germany
- Contact:
Re: SEO Metatag Info - fine plugin with extensive functions
Hmm, in FlatPress 1.4.1, Smarty compiles array accesses ($_tpl_vars[‘seo_desc’]), which I had overlooked or ignored until now.
I have also incorporated
this patch into this version.
The template remains as in this comment.
This should allow it to work without Smarty4 errors.
I have also incorporated
this patch into this version.
Code: Select all
// Establish compatibility with older Smarty 4.
function seometataginfo_assign_defaults() {
if (isset($GLOBALS ['smarty']) && is_object($GLOBALS ['smarty']) && method_exists($GLOBALS ['smarty'], 'assign')) {
$GLOBALS ['smarty']->assign('seo_desc', '');
$GLOBALS ['smarty']->assign('seo_keywords', '');
}
}
add_action('init', 'seometataginfo_assign_defaults', 0);This should allow it to work without Smarty4 errors.
My
Re: SEO Metatag Info - fine plugin with extensive functions
Hello Frank,
Thank you, with the Git version it is working properly, the modification for Smarty 4 only eliminated the entry in the error log, but there was no output of the variables.
Thank you, with the Git version it is working properly, the modification for Smarty 4 only eliminated the entry in the error log, but there was no output of the variables.
Who is online
Users browsing this forum: No registered users and 0 guests