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

Help needed with my first plugin - a space issue

Development and Programming

pushloop's avatar
pushloop
422 posts
about 16 years ago
pushloop's avatar pushloop

Hey

I need to turn every word in a string into an include. So despite my lack of php skills I thought I’d try to build my very first plug-in to handle things, but I’ve run into some issues…

First, the idea is to take a custom field and turn every word in that field into an embed, or in my case, an include.

{exp:weblog:entries weblog="main"}

 {exp:explodeinclude url="http://www.example.com/index.php/modules/"}
  {modules}
 {/exp:explodeinclude}

{/exp:weblog:entries}

Should be simple, right? Well, below is what I’ve got so far. Please bare in mind that I don’t actually know php… 😛

class Explodeinclude
{

var $return_data = "";

  function Explodeinclude()
  {
    global $TMPL;
    
    $url = $TMPL->fetch_param('url');
    $url = str_replace( "/","/",$url); 
    
    // Input string
    $string = $TMPL->tagdata;

    // Create an array from input
    $modules = explode(',',strtolower($string));
    
    // Add all found words to the new array
    foreach($modules as $module){
        include($url.$module);
       }


    $this->return_data = $TMPL->tagdata;
  }

}

The issues I’ve got are:

  1. Even if placed under a heading and other content, the code rendered by the plugin is displayed at the very top of the page.

  2. A space is placed in front of the $module segment of the url.

  3. It would be great if I could just specify the template group and template instead of the full url. Although I’m not sure if it’ll work as I may have to use the server path anyway…

Any help would be much appreciated!

Tnx /André

       
pushloop's avatar
pushloop
422 posts
about 16 years ago
pushloop's avatar pushloop

I just realized that I probably can’t place an include the way I have, because I assume that means that the actual plugin file is requesting something to be included into it, right?

Any ideas how to do this?!

       
pushloop's avatar
pushloop
422 posts
about 16 years ago
pushloop's avatar pushloop

F.y.i. I have given up on this quest for now and decided to go with one drop-down for each module instead 😛 If anyone comes up with a plug-in or solution to this please (PLEASE) let me know!

Thanks for all your input guys!

/A

       

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.