Order by in custom template

yosemite 15 Jan, 2015
Hi,

I created a custom template for the frontend display but I can't find how to create an "Order by" field with multiple options in the header.

Plus I have an issue creating a condition using PHP. My PHP seems correct to me but doesn't work at all. It's supposed to show a "No picture" image when the image field is empty. Here's the code :

<?php
$image =  '{Barrier.image}';
if( $image == "" ) { echo '<img style="float:left; border:1px solid silver;" src="/components/com_chronocontact/uploads/nofile.jpg" />'; 
} else {
echo '<img style="float:left; border:1px solid silver;" src="/images/barriers/{Barrier.image}_big" />'; }
?>


Thank you for your help !
Quentin
GreyHead 16 Jan, 2015
Hi Quentin,

Sorry, I don't understand the header problem.

The second one is probably because you can't use the {} syntax inside <?php . . . ?> tags; use the PHP variable name instead. I think that is now $row so $row['Barrier']['image'] but I can't see it in any of the FAQs :-(

Bob
yosemite 16 Jan, 2015
Hi Bob,

Thank you for your answer, I changed the variable value to $row['Barrier']['image'] and it works.

Sorry if I wasn't clear on my header problem. I have a custom display with a search in the header, I would like to add a select field for users to choose the ordering option of the displayed list.

Quentin
GreyHead 16 Jan, 2015
Hi Quentin,

I don't know how to do that - though it is probably possible.

You can use the Sortables box in the setup to set up column headers that will sort when clicked - similar to the Joomla! Admin sortable columns. Would that work?

Bob
yosemite 30 Jan, 2015
Hi Bob,

Couldn't find a way to use the Sortable box, they change the order of the articles but I can't switch from one to another on the frontend.

Quentin
Max_admin 04 Feb, 2015
Answer
1 Likes
Hi,

If the field name is in the "Columns list" and is in the "Sortable" then using the field name between curly brackets in the "header" box should display a sorting link!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
yosemite 05 Feb, 2015
That's perfect, thanks to both of you for your help !

Quentin
This topic is locked and no more replies can be posted.