joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.77k stars 3.65k forks source link

J4.4.9 Author alias not loading on article instead of created by #44374

Closed fusedNL closed 3 weeks ago

fusedNL commented 3 weeks ago
  1. Create an article
  2. Under publishing put a different name for Author alias
  3. Load the article on the front end

Input:

Image

Output: Image

Desired output: Name should be the created by alias

fgsw commented 3 weeks ago

Can't confirm:

Image Image

fusedNL commented 3 weeks ago

What could possibly be the issue here? I have loaded through a custom layout override the following code to debug.

<?php // Force the use of created_by_alias if it exists, or fallback to author $this->item->author = !empty($this->item->created_by_alias) ? $this->item->created_by_alias : $this->item->author; echo 'Debug Author Alias: ' . $this->item->author; ?>

Other steps I have tried are checking the database direct, clearing the cache, all to no resulkt.

brianteeman commented 3 weeks ago

Have a look t how core joomla does this. The code is in layouts\joomla\content\info_block\author.php

fusedNL commented 3 weeks ago

@brianteeman yes, that is where I copied the override from. It looks working there but just doesnt render the output the same way. So cannot find anything odd in the database or the core / overrides.

As a background it is a site migrated from J3 to J4. I added a new article into the system and it brings the same result. The alias is not loaded.

<?php

/**
 * @package     Joomla.Site
 * @subpackage  Layout
 *
 * @copyright   (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

?>
<dd class="createdby" itemprop="author" itemscope itemtype="https://schema.org/Person">
    <span class="icon-user icon-fw" aria-hidden="true"></span>
    <?php $author = ($displayData['item']->created_by_alias ?: $displayData['item']->author); ?>
    <?php $author = '<span itemprop="name">' . $author . '</span>'; ?>
    <?php if (!empty($displayData['item']->contact_link) && $displayData['params']->get('link_author') == true) : ?>
        <?php echo Text::sprintf('COM_CONTENT_WRITTEN_BY', HTMLHelper::_('link', $displayData['item']->contact_link, $author, ['itemprop' => 'url'])); ?>
    <?php else : ?>
        <?php echo Text::sprintf('COM_CONTENT_WRITTEN_BY', $author); ?>
    <?php endif; ?>
</dd>
brianteeman commented 3 weeks ago

without seeing the rest of your template, overrides etc its not possible to comment further. Even with that information this is not the place to fix the code in your template.

Quy commented 3 weeks ago

Please submit to Joomla forum for support. https://forum.joomla.org/

fusedNL commented 3 weeks ago

@brianteeman agreed, even with any of the overrides disabled it still isnt working out of the box. Thought it might be a bug in the core hence my post here. I will check whether the current site template has issues.