Hi. Quick question. If I have a PHP Function that takes in a parameter and runs PHP code, how can I use this EASILY in EE?
I want to be able to use like {exp:blah myfunction:path} or {MYFUNCTION:PATH}. Aka: User-Friendly.
My php code is like this:
<?php
function myfunction( $fullPath ){
phpcode( $fullPath );
} else
die('Path Not Found');
}
?>Do I just place that php code in a snippet or template? Then call it somehow?
Thanks.
The quickest way to work with PHP would be to include it in your templates directly and enable PHP parsing on that particular template. However, a cleaner way to achieve it (and one that helps avoid potential parsing issues [PDF]) is to convert that PHP code into an ExpressionEngine plugin. Here are some helpful docs on how to do just that thing.
Does that help?
A follow up question here. Are methods of a plugin callable from a different plugin? This goes to scope and how to proceed when you need bits and pieces that are already available, but need to integrate these with some custom code.
A somewhat different question is how to access say a session variable set using a plugin or php from Jquery.
Both questions address the problem of being able to link different procedures/functions in order to achieve the desired results.
Hi icebreaker,
Addons are designed to be usable independent of one another, so there isn’t an “official” way to do that. If you’re working on custom solution where you know a set of files will always exist, you can certainly include those from within multiple add-ons.
Shifting this over to Development and Programming to get you further input. Thanks!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.