changes to CHtml tag

Discuss everything related to ApPHP MVC Framework. All versions. Any questions related to the Framework developing or using should be posted to this forum.

Moderators: alexandrleonenko, alexmst

paragate
Master
Master
Posts: 151
Joined: Nov 13th, '14, 13:04
Location: Denmark, Odense

changes to CHtml tag

Postby paragate » Sep 10th, '16, 18:05

hi,
having problem with nesting of functions
would like to generate this tag:

Code: Select all

<a title="veganbutcher" href="#"><span><img src="js/vendors/wowsliderdata1/images/veganbutcher.jpg" alt="veganbutcher" />1</span></a>

the problem is that a $text var is missing in the CHtml function tag.
the reason is that

Code: Select all

 $spanVarImg = CHtml::image('js/vendors/wowsliderdata1/images/veganbutcher.jpg', 'veganbutcher');
 $output .= CHtml::link(CHtml::tag('span',array(), $spanVarImg, true), '#', array('class'=>'', 'title'=>'veganbutcher')).self::NL;

will generate

Code: Select all

<a title="veganbutcher" href="#"><span><img src="js/vendors/wowsliderdata1/images/veganbutcher.jpg" alt="veganbutcher" /></span></a>

whithout the "1" in the span tag
The CHtml.php look like this:

Code: Select all

public static function tag($tag, $htmlOptions = array(), $content = false, $closeTag = true')
   {
      $html = '<'.$tag.self::_renderAttributes($htmlOptions);
      if($content === false){
         return $closeTag ? $html.' />' : $html.'>';
      }else{
         return $closeTag ? $html.'>'.$content. '</'.$tag.'>' : $html.'>'.$content;
      }
   }

is it possible to change it to:

Code: Select all

public static function tag($tag, $htmlOptions = array(), $content = false, $closeTag = true, $text ='')
   {
      $html = '<'.$tag.self::_renderAttributes($htmlOptions);
      if($content === false){
         return $closeTag ? $html.' />' : $html.'>';
      }else{
         return $closeTag ? $html.'>'.$content. $text. '</'.$tag.'>' : $html.'>'.$content;
      }
   }

$output .= CHtml::link(CHtml::tag('span',array(), $spanmid, true, '1'), '#', array('class'=>'', 'title'=>'veganbutcher')).self::NL;

then it will generate:

Code: Select all

<a title="veganbutcher" href="#"><span><img src="js/vendors/wowsliderdata1/images/veganbutcher.jpg" alt="veganbutcher" />1</span></a>


Or is there a better solution??

administrator
Site Admin
Site Admin
Posts: 5997
Joined: Jan 7th, '09, 23:18
Contact:

Re: changes to CHtml tag

Postby administrator » Sep 11th, '16, 09:05

Instead of using additional parameter $text, just pass a reqired text via parameter $content

paragate
Master
Master
Posts: 151
Joined: Nov 13th, '14, 13:04
Location: Denmark, Odense

Re: changes to CHtml tag

Postby paragate » Sep 11th, '16, 09:38

But as you can see the $content is allready in use. The <span> do not generate anything unless i use $text.

ne_moj
Master
Master
Posts: 243
Joined: Jan 1st, '16, 14:11

Re: changes to CHtml tag

Postby ne_moj » Sep 13th, '16, 08:50

Hello

Use the concatenation ==> $spanVarImg . '1':

Code: Select all

$spanVarImg = CHtml::image('js/vendors/wowsliderdata1/images/veganbutcher.jpg', 'veganbutcher');
$output .= CHtml::link(CHtml::tag('span',array(), $spanVarImg.'1', true), '#', array('class'=>'', 'title'=>'veganbutcher')).self::NL;

paragate
Master
Master
Posts: 151
Joined: Nov 13th, '14, 13:04
Location: Denmark, Odense

Re: changes to CHtml tag

Postby paragate » Sep 13th, '16, 16:38

Super Thanks..

Did not know about concatenation that way..
Then i have a complete Banner Wowslider Module, using the wowslider engine


Return to “ApPHP MVC Framework {developers/users}”