PHP in custom fields

Get help from the community here.

Moderator: Developers

amdoffshore
Posts: 16
Joined: Tue Oct 01, 2013 7:20 am

PHP in custom fields

Postby amdoffshore » Tue Feb 17, 2015 9:24 am

Hi there,

Custom Fields for Contacts:
I want to create links which is working in general. Anyhow, in case there is nothing in the custom fields I want to search for the name of the contact. How do I pick up the name here?

if($cf->col_80<10)
{
return first_name;
}
else
{
return $cf->col_80;
}

Thanks and best regards

Martin
mschering
Site Admin
Site Admin
Posts: 8154
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: PHP in custom fields

Postby mschering » Fri Feb 20, 2015 8:53 am

Something like this:

$contact = Contact::model()->findByPk($cf->model_id);

$contact->first_name;
Best regards,

Merijn Schering
Intermesh
michaeled
Posts: 86
Joined: Wed May 09, 2012 2:00 pm

Re: PHP in custom fields

Postby michaeled » Mon Feb 15, 2016 11:01 am

Hi,

I'd like to add this php in customfield, but it does'n work :

Code: Select all

echo "anything";

I'd like to add a link (maybe a button) with some dynamic value.

How can I do that ?

Thank you,

Best regards,

Michael
mschering
Site Admin
Site Admin
Posts: 8154
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: PHP in custom fields

Postby mschering » Thu Feb 25, 2016 8:46 am

I'm sorry but that's not possible.
Best regards,



Merijn Schering

Intermesh
amdoffshore
Posts: 16
Joined: Tue Oct 01, 2013 7:20 am

Re: PHP in custom fields

Postby amdoffshore » Wed Jul 19, 2017 8:05 am

Hi,
is it in general not possible to insert dynamic content?
I would like to insert: https://www.marinetraffic.com/de/p/embed-map
-> a small map linking to the present location of vessels.
This is not giving any error:

Code: Select all

return "<script type=\"text/javascript\">
   width='425';
   height='350';
   border='1';
   shownames='false';
   latitude='37.4460';
   longitude='24.9467';
   zoom='9';
   maptype='1';
   trackvessel='0';
   fleet='';
   </script>
   <script type=\"text/javascript\" src=\"https://www.marinetraffic.com/js/embed.js\"></script>";

If I look at the sorce code of the page I can see this as HTML. Anyhow it is not being displayed.

Additionally I would like to have following integrated:
http://wiki.openseamap.org/index.php?title=OpenSeaMap_in_Website
-> Embed as Slippy-Map

Code: Select all

return "<iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\"
src=\"http://www.openseamap.org/export/embed.html?bbox=-2.01,43.15,13.85,53.35&layer=mapnik\"
style=\"border: 1px solid black\"></iframe>
<a href=\"http://www.openseamap.org/?lat=48.25&lon=5.92&zoom=5&layers=BFTTFFTFFTF0FF\">Größere Karte anzeigen</a>";

This inserts a frame with given size. Anyhow nothing is opened inside.

This would easy up a lot of things.

Thanks

Martin

Return to “General help”

Who is online

Users browsing this forum: No registered users and 3 guests

cron