Yii Framework Forum: How Yii Generates Dom - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How Yii Generates Dom Rate Topic: -----

#1 User is offline   veontomo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 19-October 12

Posted 16 June 2013 - 01:24 PM

Dear friends,
I'm experiencing a behaviour of Yii that illustrates that I must be missing something.
To be short: this is the code in view/layouts/main.php:

<div class="large-3 columns">
 <?php  
  $this->renderPartial("/categories/_small");
  echo "some test text";
 ?>
</div>
<footer>This is a footer</footer>


Strange enough, but the generated html

<div class="large-3 columns">
   <ul id="yw0">... text from render partial goes here ... </ul>
  <div style="clear:both;"> some test text </div> <---- WHERE THIS DIV TAG COMES FROM?!
  <footer> This is a footer </footer> <---- WHY IS IT NESTED INSIDE THE DIV?
</div>

is quite different from what I was expecting:
<div class="large-3 columns">
   text from render partial goes here 
   some test text <--- WITHOUT ANY ADDITIONAL DIV TAG
</div>
<footer> This is a footer </footer> <---- NOT NESTED INSIDE DIV TAG


Could anybody shed ligth on what's wrong here and how to generate desired html?
The more one gets to know of Yii, the more one values Yii.
0

#2 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,317
  • Joined: 21-February 11
  • Location:Greece

Posted 16 June 2013 - 02:58 PM

comment that
//$this->renderPartial("/categories/_small");

If the problem be solved check your _small view file

In any case, I am sure that you have forget to close a tag! :)
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#3 User is offline   veontomo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 19-October 12

Posted 16 June 2013 - 03:28 PM

Most probably, you're right. I noticed that with commenting that line, the problem disappears.
But the _small view contains this code:

<?php
$rootCat=Categories::model()->findByPk('0');
$items=array();
$items[]=$rootCat->getListed(); 
$this->widget('CDropDownMenu',array(
    'items'=>$items[0]['items'],
    'htmlOptions'=>array('class'=>'side-nav')
));
?>


(please, don't kill me for this cose, it's a legacy one). And I don't see any missing tag.
The more one gets to know of Yii, the more one values Yii.
0

#4 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,317
  • Joined: 21-February 11
  • Location:Greece

Posted 16 June 2013 - 03:54 PM

View Postveontomo, on 16 June 2013 - 03:28 PM, said:

Most probably, you're right. I noticed that with commenting that line, the problem disappears.
But the _small view contains this code:

<?php
$rootCat=Categories::model()->findByPk('0');
$items=array();
$items[]=$rootCat->getListed(); 
$this->widget('CDropDownMenu',array(
    'items'=>$items[0]['items'],
    'htmlOptions'=>array('class'=>'side-nav')
));
?>


(please, don't kill me for this cose, it's a legacy one). And I don't see any missing tag.


ha, no I will not 'kill' you :)

did you use this extension?
http://www.yiiframew.../cdropdownmenu/

comment this widget and check this code
echo CHtml::dropDownList('modelname', $items[0]['items'][0], $items[0]['items']);


also comment both of them to check if the problem will be fixed
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#5 User is offline   veontomo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 19-October 12

Posted 16 June 2013 - 04:34 PM

Thanks for not killing me :-)
Concerning the problem:
  • if I comment lines corresponding to $this->widget(...), the problem dispapears.

  • if I insert the code that you suggested

    echo CHtml::dropDownList('modelname', $items[0]['items'][0], $items[0]['items']);

    (with the widget lines being commented), the problem persists.

  • even more interesting: if I drop out the arguments of the widget, so that it acquires the form

    $this->widget('CDropDownMenu',array());

    the problem still persists!

Probably I'm using the widget in a wrong way??
The more one gets to know of Yii, the more one values Yii.
0

#6 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,317
  • Joined: 21-February 11
  • Location:Greece

Posted 16 June 2013 - 04:49 PM

View Postveontomo, on 16 June 2013 - 04:34 PM, said:

Thanks for not killing me :-)
Concerning the problem:
  • if I comment lines corresponding to $this->widget(...), the problem dispapears.

  • if I insert the code that you suggested

    echo CHtml::dropDownList('modelname', $items[0]['items'][0], $items[0]['items']);

    (with the widget lines being commented), the problem persists.

  • even more interesting: if I drop out the arguments of the widget, so that it acquires the form

    $this->widget('CDropDownMenu',array());

    the problem still persists!

Probably I'm using the widget in a wrong way??



may the $items[0] has problem
check this
echo CHtml::dropDownList('modelname', 1, array(1=>'item1',2=>'item1',1=>'item3'));


or make a similar check with the widget
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#7 User is offline   veontomo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 19-October 12

Posted 16 June 2013 - 05:15 PM

I've just now found the origin of the bug: the widget in its turn referred to extentions/CDropDownMenu.php, which method

protected function renderDropDownMenu(...)


contained unbalanced

echo '<div style="clear:both;">';


So, it is exactly as you had said: the presence of an unclosed tag! Thanks a lot!
The more one gets to know of Yii, the more one values Yii.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users