0

I'm having a problem using a helper in cakephp. Helper has an error loading an element into a plugin.

how to run this function below inside the above array. For in the example I got on the internet is exactly like that and nobody accused any problem.

Can someone help me?

ShortcodeHelper.php

<?php    
App::import('Helper', 'Html', 'Router');
class ShortcodeHelper extends AppHelper {
    public $shortcodes = array( 
        'slideshow' => '/(\[slideshow=)(.+?)(\])(.+?)(\[\/slideshow\])/'
    ); 
    public $returncodes = array( 
        'slideshow' => $this->render('/elements/slideshow', array('id'=>'\\2'))
        //'slideshow' => '<strong rel="\\2">\\4</strong>' 
    ); 

    public function render($content, $render=null) {
        $shortcodes = $this->shortcodes;
        $returncodes = $this->returncodes;
        if(isset($render)) {
                $temp_shortcodes = array(); 
                $temp_returncodes = array(); 
                foreach ($render as $key => $value) { 
                    $temp_shortcodes[$key] = $shortcodes[$value]; 
                    $temp_returncodes[$key] = $returncodes[$value]; 
                } 
                $returncodes = $temp_returncodes; 
                $shortcodes = $temp_shortcodes; 

        }
        $return = preg_replace($shortcodes, $returncodes,  $content); 
        return $this->output($return); 
    }
}

Error

Parse error: syntax error, unexpected '$this' (T_VARIABLE) in /home/testsite/public_html/app/Plugin/Slideshow/View/Helper/ShortcodeHelper.php on line 11

thanks in advance

Goof
  • 17
  • 2
  • Read the error message and google it if you don't know what it means It's *very* unlikely that you're the first person to encounter a language error and it's not documented... https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php – floriank Sep 20 '17 at 16:33
  • ah yes burzum. My problem is not the error message. This I know what it means, I think I formulated the question wrong. The question is how to run this function below inside the above array. For in the example I got on the internet is exactly like that and nobody accused that it gave problem. I thought it was strange. Sorry about that. – Goof Sep 20 '17 at 16:51
  • That's simply invalid PHP, class properties can only be initialized with constant values that can be evaluated at compile time, method/function calls are not supported. **http://php.net/en/language.oop5.properties**, **https://stackoverflow.com/questions/27154443/using-this-in-an-array-is-causing-unexpected-t-variable** – ndm Sep 20 '17 at 18:58

0 Answers0