Search
Other Articles Anywhere questions
Forum

Help with displaying custom fields

trey braid's Avatar trey braid
Peter I just bought articles anywhere pro to display custom fields. I am using custom fields to create a roster page for a football team.

I've added this and of course, it is not working...category is "Roster" and the [fields] are below

[articles category="Roster"}[headshots][no][name][position][height][weight][college][hometown][experience]{/articles}

I was talking with another individual who said using articles anywhere with custom fields would be the way to display the articles in a table format with the fields in columns

gobandits.fun/NEW/team/roster.html

Confidential information:
(hidden)


Thanks
Trey
Peter van Westen's Avatar Peter van Westen ADMIN
By the looks of it, your syntax is not correct.
You are starting with a square bracket. That should be a curly brace.

I recommend you first try some simple stuff with Articles Anywhere to see how it works. If you get the simple stuff working, move on to crazier stuff.

Also: read the documentation:
docs3.regularlabs.com/articlesanywhere
Please post a rating at the Joomla! Extensions Directory
trey braid's Avatar trey braid
Thanks Peter, I added the curly bracket at the beginning and it's working...

Now I just need to adjust the image size and layout so each record is in a tabular row. Is there a layout override I can apply or edit to accomplish that?

Trey
trey braid's Avatar trey braid
Peter, I downloaded the render.php file for the overrides. What changes would I need to make to this code so each article is on its own row in a table?

As you can see the custom fields and image are all stacked running into each other

gobandits.fun/NEW/team/roster.html
<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_fields
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;

if (!key_exists('field', $displayData))
{
	return;
}

$field = $displayData['field'];
$label = JText::_($field->label);
$value = $field->value;
$showLabel = $field->params->get('showlabel');
$labelClass = $field->params->get('label_render_class');
$renderClass = $field->params->get('render_class');

if ($value == '')
{
	return;
}

?>
<?php if ($showLabel == 1) : ?>
	<span class="field-label <?php echo $labelClass; ?>"><?php echo htmlentities($label, ENT_QUOTES | ENT_IGNORE, 'UTF-8'); ?>: </span>
<?php endif; ?>
<span class="field-value <?php echo $renderClass; ?>"><?php echo $value; ?></span>

Thanks again for your help!!!
Peter van Westen's Avatar Peter van Westen ADMIN
In your {articles} tag you are telling Articles Anywhere to output all that data simply separated with 2 spaces. So that's what it does.

If you want each article on a new table row, and the entire thing inside a table, you need to place the data tags in separate table rows.

Like I said, try to first do something simple so that you understand how Articles Anywhere works, and how to use the syntax.
And also, read the documentation and look at the examples given.
Please post a rating at the Joomla! Extensions Directory
trey braid's Avatar trey braid
I don't understand data tags, this is going to be a roster page of football players. Am I going to have to add a "tag" to every player?

Each article is just 8 custom fields and the intro-image.

Can I use bootstrap instead of a table to create the columns?
trey braid's Avatar trey braid
Ok, I added a tag called "Players" and that did the trick with the output for each article on a row to a degree though it overflows from 1 row to another. I did some reading where I saw you could apply and <H> tag for font size - I added <H5> and gave it a size specifically for this page.

<div class="row">{articles category="Roster"}
<h5 class="col-lg-1" style="text-align: right;">[image-intro layout="true"]</h5>
<h5 class="col-lg-1" style="text-align: left;">[no]</h5>
<h5 class="col-lg-2" style="text-align: left;">[link][title][/link]</h5>
<h5 class="col-lg-1" style="text-align: left;">[position]</h5>
<h5 class="col-lg-1" style="text-align: left;">[height] [weight]</h5>
<h5 class="col-lg-3" style="text-align: left;">[college]</h5>
<h5 class="col-lg-2" style="text-align: left;">[hometown]</h5>
<h5 class="col-lg-1" style="text-align: left;">[experience]</h5>
[tags]{/articles}
</div>

Is it possible in Joomla to automatically add the tad when an article assigned to a specific category?

Thanks again for your help!!!
trey braid's Avatar trey braid
I tried adding a responsive table and it's also a bit messed up... what did I mess up with this? Should I try and get it to work with this or with the bootstrap "col-lg" in my earlier post. Please let me know what you think is the best way to proceed.

gobandits.fun/NEW/roster1.html
<table class="table table-hover">
	<thead>
		<tr>
			<th scope="col">Image</th>
			<th scope="col">#</th>
			<th scope="col">Name</th>
			<th scope="col">Position</th>
			<th scope="col">Ht</th>
			<th scope="col">Wt</th>
			<th scope="col">College</th>
			<th scope="col">Hometown</th>
			<th scope="col">Experience]</th>
		</tr>
	</thead>
	<tbody>
		<tr>{articles category="Roster"}<th scope="row">[image-intro layout="true"]</th>
			<td>[no]</td>
			<td>[link][title][/link]</td>
			<td>[position]</td>
			<td>[height]</td>
			<td>[weight]</td>
			<td>[college]</td>
			<td>[hometown]</td>
			<td>[experience][tags]</td>
			{/articles}
		</tr>
	</tbody>
</table>

Thanks again for putting up with all my questions.
Trey
Andrea Malalana's Avatar Andrea Malalana ADMIN
Hey there,

By reading the ticket I see that you're not very familiar with HTML/CSS in general... for that I suggest to ask help in a general HTML/CSS forum / StackOverflow for how to better style stuff (using tables, or bootstrap, headings etc...)

Now, regarding Articles Anywhere, if you plan to use a table, the correct syntax would be this:
<table class="table table-hover">
	<thead>
		<tr>
			<th scope="col">Image</th>
			<th scope="col">#</th>
			<th scope="col">Name</th>
			<th scope="col">Position</th>
			<th scope="col">Ht</th>
			<th scope="col">Wt</th>
			<th scope="col">College</th>
			<th scope="col">Hometown</th>
			<th scope="col">Experience]</th>
		</tr>
	</thead>
	<tbody>
    {articles category="Roster"}
		<tr>
            <td>[image-intro layout="true"]</td>
			<td>[no]</td>
			<td>[link][title][/link]</td>
			<td>[position]</td>
			<td>[height]</td>
			<td>[weight]</td>
			<td>[college]</td>
			<td>[hometown]</td>
			<td>[experience][tags]</td>
		</tr>
     {/articles}
	</tbody>
</table>

As you can see, the {articles} tag should sit OUTSIDE of the <tr>, because we want to repeat the data for every row.

However, the "issue" of trying to put Articles Anywhere in a table is that, usually, the Joomla editor (eg. JCE) will mess up the syntax once you save it.

So using bootstrap columns would actually be an easier solution. In that case, you'd need to put the {articles} tag outside of the <div class"row">, not inside.

In alternative, if you really want to use a table, you can do a little "hack" and use this code:
<table class="table table-hover">
	<thead>
		<tr>
			<th scope="col">Image</th>
			<th scope="col">#</th>
			<th scope="col">Name</th>
			<th scope="col">Position</th>
			<th scope="col">Ht</th>
			<th scope="col">Wt</th>
			<th scope="col">College</th>
			<th scope="col">Hometown</th>
			<th scope="col">Experience]</th>
		</tr>
	</thead>
	<tbody>
		<tr>
            <td>{articles category="Roster"}[image-intro layout="true"]</td>
			<td>[no]</td>
			<td>[link][title][/link]</td>
			<td>[position]</td>
			<td>[height]</td>
			<td>[weight]</td>
			<td>[college]</td>
			<td>[hometown]</td>
			<td>[experience][tags]</td>
		</tr>
		<tr>
           <td>{/articles}</td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
	</tbody>
</table>

The only "downside" of this work-around is that you'll have an extra empty row at the bottom.

Let me know if this helps.
trey braid's Avatar trey braid
Thank you
Trey
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription