We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

If I have a PHP function that takes in a parameter, how can I use this in EE? Snippet? Template? Addon?

Development and Programming

txdigital's avatar
txdigital
17 posts
14 years ago
txdigital's avatar txdigital

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.

       
Kevin Smith's avatar
Kevin Smith
4,784 posts
14 years ago
Kevin Smith's avatar Kevin Smith

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?

       
txdigital's avatar
txdigital
17 posts
14 years ago
txdigital's avatar txdigital

thanks! helps a bunch. As long as I know where to get started 😊

       
icebreaker's avatar
icebreaker
50 posts
14 years ago
icebreaker's avatar icebreaker

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.

       
Brandon Jones's avatar
Brandon Jones
5,500 posts
14 years ago
Brandon Jones's avatar Brandon Jones

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!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.