*

Own Petz

  • ****
  • 210 posts
  • OwnPetz - Free Classified Ads. Buy, Sell or Adopt
Blog Plugin Structure Data Error
« on: September 05, 2025, 06:49:57 AM »
Hi,

Thanks for your previous help..


I have added these script in article.php

<script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "Article",
      "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "<?php echo osc_esc_html($blog_url); ?>"  },
      "headline": "<?php echo blg_get_title($blog); ?>",
      "description": "<?php echo osc_esc_html(osc_highlight(osc_structured_data_description(), 200)); ?>",
      "image": "<?php echo blg_img_link($blog['s_image']); ?>",
      "datePublished": "<?php echo date('j M Y', strtotime($blog['dt_pub_date'])); ?>",
      "author": [{
          "@type": "Person",
          "name": "<?php echo $author['s_name']; ?>",
          "url": "<?php echo osc_route_url('blg-author', array('authorSlug' => osc_sanitizeString(blg_slug($author['s_name'])), 'authorId' => $author['pk_i_id'])); ?>"
        }]
    }
    </script>

output showing good ..

But in error log showing error in


[05-Sep-2025 09:28:48 Asia/Kolkata] PHP Warning:  Undefined array key "s_name" in /home/cpkgkd18vzkh/public_html/oc-content/plugins/blog/form/article.php on line 37
[05-Sep-2025 09:28:48 Asia/Kolkata] PHP Warning:  Undefined array key "s_name" in /home/cpkgkd18vzkh/public_html/oc-content/plugins/blog/form/article.php on line 38

This is

Line 37

"name": "<?php echo $author['s_name']; ?>",

Line 38
"url": "<?php echo osc_route_url('blg-author', array('authorSlug' => osc_sanitizeString(blg_slug($author['s_name'])), 'authorId' => $author['pk_i_id'])); ?>"



and also getting this error in head.php

[05-Sep-2025 12:33:15 Asia/Kolkata] PHP Warning:  Trying to access array offset on false in /home/cpkgkd18vzkh/public_html/oc-content/themes/delta/head.php on line 33

line 33 in head.php - var delCurrentLocale = '<?php echo osc_esc_js($current_locale['s_name']); ?>';

can you please rewrite this

Thanks.
« Last Edit: September 05, 2025, 09:19:06 AM by Own Petz »
OwnPetz - Free Classified Ads. Buy, Sell or Adopt Online. https://ownpetz.com

*

Own Petz

  • ****
  • 210 posts
  • OwnPetz - Free Classified Ads. Buy, Sell or Adopt
Re: Blog Plugin Structure Data Error
« Reply #1 on: September 05, 2025, 10:36:43 AM »
I think I have fixed this error

for article.php

I have write and change in script

<?php
  // Fallbacks for missing blog/author data
  $blog_title       = isset($blog['s_title']) ? blg_get_title($blog) : 'Untitled Article';
  $blog_description = osc_esc_html(osc_highlight(osc_structured_data_description(), 200));
  $blog_image       = isset($blog['s_image']) ? blg_img_link($blog['s_image']) : osc_resource_url('images/no_image_available.png');
  $blog_date        = isset($blog['dt_pub_date']) ? date('c', strtotime($blog['dt_pub_date'])) : date('c');

  $author_name = isset($author['s_name']) ? $author['s_name'] : 'Guest Author';
  $author_id   = isset($author['pk_i_id']) ? $author['pk_i_id'] : 0;
  $author_url  = $author_id > 0
    ? osc_route_url('blg-author', array(
        'authorSlug' => osc_sanitizeString(blg_slug($author_name)),
        'authorId'   => $author_id
      ))
    : osc_base_url();
?>

    <script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "<?php echo osc_esc_html($blog_url); ?>"
  },
  "headline": "<?php echo osc_esc_html($blog_title); ?>",
  "description": "<?php echo $blog_description; ?>",
  "image": "<?php echo $blog_image; ?>",
  "datePublished": "<?php echo $blog_date; ?>",
  "author": [{
    "@type": "Person",
    "name": "<?php echo osc_esc_html($author_name); ?>",
    "url": "<?php echo $author_url; ?>"
  }]
}
</script>



and in head.php , I have changed this

This

<?php
  $current_locale = osc_get_current_user_locale();
  $dimNormal = explode('x', osc_get_preference('dimNormal', 'osclass'));

  $jquery_version = (defined('JQUERY_VERSION') && JQUERY_VERSION != '1') ? JQUERY_VERSION : '1';
?>
<script type="text/javascript">
  var delCurrentLocale = '<?php echo osc_esc_js($current_locale['s_name']); ?>';


To

<?php
  $current_locale = osc_get_current_user_locale();
  $dimNormal = explode('x', osc_get_preference('dimNormal', 'osclass'));
  $jquery_version = (defined('JQUERY_VERSION') && JQUERY_VERSION != '1') ? JQUERY_VERSION : '1';

  // Safe locale name
  $locale_name = (is_array($current_locale) && isset($current_locale['s_name']))
    ? $current_locale['s_name']
    : osc_current_user_locale(); // fallback to site locale
?>
<script type="text/javascript">
  var delCurrentLocale = '<?php echo osc_esc_js($locale_name); ?>';

can you please check everythink is ok.. now error not showing ... lets see after sometimes.
OwnPetz - Free Classified Ads. Buy, Sell or Adopt Online. https://ownpetz.com

*

MB Themes

Re: Blog Plugin Structure Data Error
« Reply #2 on: September 05, 2025, 01:32:10 PM »
Maybe you just need to get user object into $author variable.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Own Petz

  • ****
  • 210 posts
  • OwnPetz - Free Classified Ads. Buy, Sell or Adopt
Re: Blog Plugin Structure Data Error
« Reply #3 on: September 05, 2025, 03:48:00 PM »
Thanks for your reply.

So , what I have to write here in Author name and Author Url.

"name": "<?php echo $author['s_name']; ?>",


"url": "<?php echo osc_route_url('blg-author', array('authorSlug' => osc_sanitizeString(blg_slug($author['s_name'])), 'authorId' => $author['pk_i_id'])); ?>"

Thanks.
OwnPetz - Free Classified Ads. Buy, Sell or Adopt Online. https://ownpetz.com

*

MB Themes

Re: Blog Plugin Structure Data Error
« Reply #4 on: September 05, 2025, 03:58:09 PM »
Code: [Select]
$author = User::newInstance()-findByPrimaryKey(...
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Own Petz

  • ****
  • 210 posts
  • OwnPetz - Free Classified Ads. Buy, Sell or Adopt
Re: Blog Plugin Structure Data Error
« Reply #5 on: September 06, 2025, 01:38:21 PM »
Thanks for reply ..


But sorry I am not understanding , its for author Name or for Author Url

where I have to write this - $author = User::newInstance()-findByPrimaryKey(...

I need for both

this (for showing Author name in structure data)

"name": "<?php echo $author['s_name']; ?>",

and this for (Showing Author Profile Url)

"url": "<?php echo osc_route_url('blg-author', array('authorSlug' => osc_sanitizeString(blg_slug($author['s_name'])), 'authorId' => $author['pk_i_id'])); ?>"


OwnPetz - Free Classified Ads. Buy, Sell or Adopt Online. https://ownpetz.com

*

Own Petz

  • ****
  • 210 posts
  • OwnPetz - Free Classified Ads. Buy, Sell or Adopt
Re: Blog Plugin Structure Data Error
« Reply #6 on: September 08, 2025, 12:43:40 PM »
and also getting this error in head.php - so what to write here -

[05-Sep-2025 12:33:15 Asia/Kolkata] PHP Warning:  Trying to access array offset on false in /home/cpkgkd18vzkh/public_html/oc-content/themes/delta/head.php on line 33

line 33 in head.php - var delCurrentLocale = '<?php echo osc_esc_js($current_locale['s_name']); ?>';
OwnPetz - Free Classified Ads. Buy, Sell or Adopt Online. https://ownpetz.com

*

MB Themes

Re: Blog Plugin Structure Data Error
« Reply #7 on: September 08, 2025, 04:55:45 PM »
Represents another issue why $current_locale does not have s_name... check your locales in backoffice, reupload theme files to server.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots