Other Articles Anywhere questions

How to display an article with regular styling except just the intro text, like blog/category format?

Carol Mattsson's Avatar Carol Mattsson

I am using Articles Anywhere for the first time. I want to display a specified article in the same format as my template would if I were displaying the article intro in a blog/category page.

That is, just like {article 234}{/article} except instead of displaying the entire article, display only the intro text and the read more link.

I have had success using {article 234}[title][cat_name][published][author_name][introtext][readmore]{/article} but all the CSS styling is gone. I can see that I can put in my own new styling, but I just want the "articles anywhere" article to look like the articles on the rest of the website, and use the settings from Joomla article manager.

(and actually [published] doesn't work but I don't know off-hand the column name in the database to use)

Thanks in advance,
Carol Mattsson
Peter van Westen's Avatar Peter van Westen ADMIN
You could try doing this by creating a custom layout (template override) for this. Then use that layout instead.

So copy this file:
templates/[YOUR TEMPLATE]/html/com_content/article/intro.php

Then strip away the part outputting the fulltext (and anything else you don't want).
Then use this to call it:
{article 234}[layout layout="intro"]{/article}
Or this, which does the same:
{article 234}[layout intro]{/article}
Please post a rating at the Joomla! Extensions Directory
Carol Mattsson's Avatar Carol Mattsson
Hi Peter,

Thank you for your quick response. I think we are getting somewhere, but not quite there yet. I tried your directions, with the result being my article displays the title and heading info as I want, but there's no body text and no read more link.

Basically, I commented out this PHP statement: echo $this->item->text;

I'm guessing I need to modify my custom layout to force the intro text and read more link to display, but the PHP is looks pretty complicated to me, I'm not sure what to change.

I'll keep examining the code in intro.php, but I could use some help.

Peter van Westen's Avatar Peter van Westen ADMIN
You need to replace:
<?php echo $this->item->text; ?>
<?php echo $this->item->introtext; ?>
Please post a rating at the Joomla! Extensions Directory
Carol Mattsson's Avatar Carol Mattsson
Thank you. I see, that's less code changes than I had made. Now I see the intro text. And now I ALMOST have the desired result. Now, how do I get the readmore link to appear?

I was able to display it in my previous version (I changed four lines of code to make the right wording appear), but you might have a simpler solution.

A side effect, less critical: I am displaying these three attributes above each article. They are displayed in this order for ordinary, non-articles-anywhere articles AND for the default layout full articles-anywhere articles:

- category
- published date
- written by

However in my modified intro.php articles-anywhere version, the order is:

- written by
- category
- published date

I'd like the order to be the same. I can't imagine why it would be different. Could be a Joomla thing. Not critical but I'd appreciate your suggestions to fix.

Thanks again,
Peter van Westen's Avatar Peter van Westen ADMIN
Customizing your layout is outside the responsibility of Articles Anywhere.
If you have specific questions on this, I recommend you visit the Joomla forum:

There is already a section in the layout file that outputs a read more button. So you can grab that and copy it to wherever you want it.
Please post a rating at the Joomla! Extensions Directory
Carol Mattsson's Avatar Carol Mattsson
Hi Peter,

OK, thanks for your help. I've made slightly different modifications to the intro.php file than you suggested, but so far it's working for me. I'll let go for now the different order of attributes above the article.

Thanks again for your speedy responses Peter. I had no idea what to do without your help. I did see in the Articles Anywhere documentation something about a custom layout (template override) but didn't know what it meant.

For others, my template is "Gantry 4 base" and I don't see an option to attach a file, so here's the text of the relevant part, starting at line 111, after "echo $this->item->toc; Look for my initials "CEM" for comments as to what I've modifed.
<!--start of display of "fulltext" - not showing this part per Articles Anywhere instructions - CEM -->
	<!--div itemprop="articleBody"-->
		<?php // echo $this->item->text; ?>
	<?php //echo "<br/><strong>Article body used to go here.</strong><br/>"; ?>
	<!--end of modification - CEM -->

	<?php if ($info == 1 || $info == 2) : ?>
		<?php if ($useDefList) : ?>
				<?php // Todo: for Joomla4 joomla.content.info_block.block can be changed to joomla.content.info_block ?>
			<?php echo JLayoutHelper::render('joomla.content.info_block.block', array('item' => $this->item, 'params' => $params, 'position' => 'below')); ?>
		<?php endif; ?>
		<?php if ($params->get('show_tags', 1) && !empty($this->item->tags->itemTags)) : ?>
			<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
			<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
		<?php endif; ?>
	<?php endif; ?>

	if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && !$this->item->paginationrelative) :
		echo $this->item->pagination;
	<?php endif; ?>
	<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '1')) || ($params->get('urls_position') == '1'))) : ?>
	<?php echo $this->loadTemplate('links'); ?>
	<?php endif; ?>
	<?php // Optional teaser intro text for guests ?>
	<!-- CEM always show intro text and readmore link -->
	<?php //elseif ($params->get('show_noauth') == true && $user->get('guest')) : ?>
	<?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?>
	<?php echo JHtml::_('content.prepare', $this->item->introtext); ?>
	<?php // Optional link to let them register to see the whole article. ?>
	<?php //if ($params->get('show_readmore') && $this->item->fulltext != null) : ?>
	<?php $menu = JFactory::getApplication()->getMenu(); ?>
	<?php $active = $menu->getActive(); ?>
	<?php $itemId = $active->id; ?>
	<?php $link = new JUri(JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false)); ?>
	<?php $link->setVar('return', base64_encode(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language))); ?>
	<p class="readmore">
		<a href="<?php echo $link; ?>" class="register">
		<?php $attribs = json_decode($this->item->attribs); ?>
		if ($attribs->alternative_readmore != null) : // CEM I made the test return false (changed == to !=), as I don't want to display "register to readmore".
		elseif ($readmore = $attribs->alternative_readmore) :
			echo $readmore;
			if ($params->get('show_readmore_title', 0) != 0) :
				echo JHtml::_('string.truncate', $this->item->title, $params->get('readmore_limit'));
		elseif ($params->get('show_readmore_title', 0) == 0) :
			echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
		else :
			echo JText::_('COM_CONTENT_READ_MORE');
			echo JHtml::_('string.truncate', $this->item->title, $params->get('readmore_limit'));
		endif; ?>
	<?php //endif; CEM ?>
	<?php endif; ?>

You may mark this issue as closed.
Carol Mattsson's Avatar Carol Mattsson
Hi Peter and all,

I have an update to Peter's answer, that works with Articles Anywhere FREE version 10.6.1. The short answer is, follow the instructions to create a template, as Peter described earlier, but to get the "intro.php" layout to apply, the data tags must look something like this:

{article 234}[article layout="intro"]{/article}

Now for the long answer. Peter, would your answer change now that we are at Articles Anywhere FREE version 10.6.1? (The website had just security updates applied for the last couple of years, but the client wants to revive the website, and I see I need to change some of my Articles Anywhere data tags.)

That is, I looked through the Articles Anywhere documentation (and this forum) but I could not find a tag that would supply what I asked for in my initial post, which is the entire article, including metadata links just as on blog/category pages, but only up to, and including, the readmore link.

Might such a data tag have been added since then?

Peter van Westen's Avatar Peter van Westen ADMIN
There is no specific article layout to do what you want.
So you would have to create your own and reference it like explained here:
Please post a rating at the Joomla! Extensions Directory
Carol Mattsson's Avatar Carol Mattsson
Hi Peter,

Thanks for your update about article layout. I looked over your link, but the part entitled Alternative Layout is not helpful to me. Because even as an experienced Joomla web developer, I have no idea what is a "layout" in Joomla. I have suggestions to improve your Article Layout documentation.

Your documentation says the layout can be placed in templates/my-template/html/com_content/article/, but WHAT do I place there?

The answer is earlier in this thread: a version of this file: components/com_content/views/article/tmpl/default.php, modified to suit.

What do I name this file? It's not clear that the layout name corresponds to the prefix part of "default.php." (I understand now that you have shown me by example. I'm thinking of your other users now.)

You write as though "article layout" is an ordinary Joomla concept. But I've never heard of it. You also parenthetically mention "template override," which I have heard of, but my few attempts over the years to actually use a template override in Joomla have just not been successful.

What I mean is, as the author of Articles Anywhere you probably understand article layouts inside and out, but someone who purchases Articles Anywhere extension may not know about it at all. So if it is an ordinary Joomla concept, surely there are some Joomla documentation links you can refer to to help your readers to understand it. I think it would be helpful to include such links in your documentation on Alternative Layout.

An aside, now that I've been working with WordPress for a few years as well as Joomla, I've learned to do template overrides in WordPress -- successfully.

You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription