ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

passing a string to a function does not work

February 27, 2009 9:04am

Subscribe [1]
  • #1 / Feb 27, 2009 9:04am

    webprouk

    69 posts

    Hi all

    I am developing a plugin to display links to others categories in a menu.
    I have a custom field for each category with no formatting, where I enter the categories names of categories I want to link to separated by a comma.

    In my template I explode the string to get the different names and pass the parameter to the plugin:

    <?php  
                  // check for related articles //
                  $Rel_Art ="{embed:Rel_Art}"; 
                  if($Rel_Art !="") { 
                       $rel_art_array = explode (',', $Rel_Art);
                       for ($i = 0; $i <count($rel_art_array); $i++){
                         $relation = $rel_art_array[$i];                     
                      ?>
                           {exp:cat_relations:get_relations relation='<?php echo $relation ?>' url='{site}index.php/'}                    
                       <?php 
                                     } 
                } ?>

    Then my function in the pi file queries the database to find a category that matches this parameter. But I don’t get any results. However if I hardcode the parameter value, it works, so the query is right.

    The problem is in this relation parameter, but when echoing it also looks fine.

    Is there anything I am missing on my php or any EE peculiarity here?

    Thank you

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases