Accessing a field in action code with php

Szczypka 23 Jan, 2015
I wrote code in view action to get some data.

I can easily get a field with the brackets notation:
{Start.email}


What I would like to do is to check if there is data in the field and if not I don't want to show the field.

How can I get Start.email in php to use it in if statement?
<?php
if(!empty($start_email))
?>


Thanks!
Max_admin 23 Jan, 2015
Answer
1 Likes
Please try this code:
pr($this->data);


Does it show you the full data list ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Szczypka 23 Jan, 2015
Great thanks. It works and I can take it from here.
momentis 23 Jan, 2015
I am trying to do the same thing. However, the solution above does not answer the question for me. Perhaps for the OP, but I cannot figure out how to do this. I have a field that may contain a URL. If there is no URL in the field, the listing should be blank. If there is a URL, I will display a hyperlink. I cannot figure out how to pull the field value into PHP.

I have tried:
$geturl = $row->data['venues']['venue_url'];


What am I missing?
Max_admin 23 Jan, 2015
Hi Rick,

That's in the "Action" code ? or in the listing ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
momentis 23 Jan, 2015
In the listing. I am lost on how to do this, so I'm sure I am WAY off!!
Max_admin 23 Jan, 2015
In the listing you will have to do it using the PHP functions box OR the HTML box:

HTML:
Model.field:array('' => '', '*' => '{Model.field}');


PHP functions:
Model.field:return (empty($cell) ? "" : $cell);
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
momentis 23 Jan, 2015
I would like to use the PHP functions box, but I am not able to get it to do what I need. If there is a URL in the field, I need the listing to use:

<a href="{venues.venue_url}" target="_blank"  class="uk-button uk-button-primary">WEB</a>


If there is nothing in the cell, it should be blank. Do I somehow insert that whole code in the PHP function you show above?
Max_admin 23 Jan, 2015
1 Likes
Yes, in your case the code should be:
Model.field:return (empty($cell) ? "" : '<a href="'.$row['venues']['venue_url'].'" target="_blank"  class="uk-button uk-button-primary">WEB</a>');
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
momentis 23 Jan, 2015
Bingo!! That did it!

Thanks so much for the help!!!

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