mocapapa  
          
              
                February 21, 2009,  7:12am
               
              41 
           
         
        
          [Revised]
For those who have an interest in the blog demo, this is a summary of the extensions.
[table]
[tr]
  [td]Extensions [/td]
  [td]Posts [/td]
  [/tr]
[tr]
  [td]Highslide[/td]
  [td]http://www.yiiframew…oc/cookbook/12/ 
http://www.yiiframew…opic,835.0.html [/td]
  [/tr]
[tr]
  [td]Calender widget[/td]
  [td]http://www.yiiframew…opic,848.0.html [/td]
  [/tr]
[tr]
  [td]Postdate widget[/td]
  [td]http://www.yiiframew…opic,850.0.html [/td]
  [/tr]
[tr]
  [td]Recent Posts widget[/td]
  [td]http://www.yiiframew…opic,852.0.html [/td]
  [/tr]
[tr]
  [td]Links widget[/td]
  [td]http://www.yiiframew…opic,865.0.html [/td]
  [/tr]
[tr]
  [td]Clock widget[/td]
  [td]It is working, but it is too domestic to be released…
http://www.yiiframew…opic,880.0.html [/td]
  [/tr]
[/table]
         
        
           
         
            
       
      
        
          
          
            KJedi  
          
              
                February 23, 2009, 12:00pm
               
              42 
           
         
        
          Any guidelines to make this multilingual?
         
        
           
         
            
       
      
        
          
          
            PsYhLo  
          
              
                February 23, 2009,  1:56pm
               
              43 
           
         
        
          Quote
The tutorial is written for the upcoming 1.0.3 release. Currently, you will need the code from SVN.
which the trunk or the branch
         
        
           
         
            
       
      
        
          
          
            mocapapa  
          
              
                February 25, 2009,  1:02pm
               
              45 
           
         
        
          [Revised on Feb. 25, 2009]
For those who have an interest in the blog demo, this is a summary of the extensions.
[table]
[tr]
  [td]Extensions [/td]
  [td]Posts [/td]
  [/tr]
[tr]
  [td]Highslide[/td]
  [td]http://www.yiiframew…oc/cookbook/12/ 
http://www.yiiframew…opic,835.0.html [/td]
  [/tr]
[tr]
  [td]Calender widget[/td]
  [td]http://www.yiiframew…opic,848.0.html [/td]
  [/tr]
[tr]
  [td]Postdate widget[/td]
  [td]http://www.yiiframew…opic,850.0.html [/td]
  [/tr]
[tr]
  [td]Recent Posts widget[/td]
  [td]http://www.yiiframew…opic,852.0.html [/td]
  [/tr]
[tr]
  [td]Links widget[/td]
  [td]http://www.yiiframew…opic,865.0.html [/td]
  [/tr]
[tr]
  [td]Clock widget[/td]
  [td]http://www.yiiframew…opic,880.0.html [/td]
  [/tr]
[tr]
  [td]Opening/Closing widgets[/td]
  [td]http://www.yiiframew…opic,916.0.html 
  [/td][/tr][/table]
source:
http://code.google.c…gdemo-enhanced/ 
         
        
           
         
            
       
      
        
          
          
            Mungo  
          
              
                March 5, 2009,  5:38pm
               
              46 
           
         
        
          Hi,
I am (a newbie) working through the Blog tutorial and am pretty confused over the tags section:
The tags field does not appear in the post form and when I add the appropriate code to try and display a box for users to type tags into I get an exception saying tag is not defined.
I've been back over the instructions a few times now and think I'm missing something silly… can anyone point me in the right direction?
If you need more details let me know.
Thanks
Mungo
         
        
           
         
            
       
      
        
          
          
            qiang  
          
              
                March 5, 2009,  5:41pm
               
              47 
           
         
        
          Which version are you using? The tutorial is for 1.0.3.
         
        
           
         
            
       
      
        
          
          
            Mungo  
          
              
                March 5, 2009,  5:48pm
               
              48 
           
         
        
          Hi Qiang,
Wow, quick reply! 
Should there be code in protected/views/post/_form.php for the tags? As there is nothing there…
Cheers
Mungo
p.s. great work, am enjoying everything so far!
         
        
           
         
            
       
      
        
          
          
            qiang  
          
              
                March 5, 2009,  5:51pm
               
              49 
           
         
        
          It should have _form.php…
         
        
           
         
            
       
      
        
          
          
            Mungo  
          
              
                March 5, 2009,  5:56pm
               
              50 
           
         
        
          yes, the file is there and contains:
<div class="simple">
<?php echo CHtml::activeLabelEx($post,'title'); ?>
<?php echo CHtml::activeTextField($post,'title',array('size'=>60,'maxlength'=>128)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($post,'content'); ?>
<?php echo CHtml::activeTextArea($post,'content',array('rows'=>6, 'cols'=>50)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($post,'contentDisplay'); ?>
<?php echo CHtml::activeTextArea($post,'contentDisplay',array('rows'=>6, 'cols'=>50)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($post,'status'); ?>
<?php echo CHtml::activeTextField($post,'status'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($post,'createTime'); ?>
<?php echo CHtml::activeTextField($post,'createTime'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($post,'updateTime'); ?>
<?php echo CHtml::activeTextField($post,'updateTime'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($post,'commentCount'); ?>
<?php echo CHtml::activeTextField($post,'commentCount'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($post,'authorId'); ?>
<?php echo CHtml::activeTextField($post,'authorId'); ?>
</div> 
When I add in:
<div class="row">
<?php echo CHtml::activeLabel($post,'tag'); ?>
<?php echo CHtml::activeTextField($post,'tag',array('size'=>65)); ?>
<p class="hint">
Separate different tags with commas.
</p>
</div> 
I get the exception that says:
Property "Post.tag" is not defined.
I've also tried this with tags, Tag and Tags
Does this help clarify my problem?
Cheers
Mungo
         
        
           
         
            
       
      
        
          
          
            qiang  
          
              
                March 5, 2009,  6:02pm
               
              51 
           
         
        
          It means the Post table in your database doesn't have the 'tags' column. It shouldn't be because the schema included in the blog demo does have this column.
         
        
           
         
            
       
      
        
          
          
            Mungo  
          
              
                March 5, 2009,  6:05pm
               
              52 
           
         
        
          OK, I understand that!
So, next question, how do I get the field to appear and create the relation between the Post table and the Tag table?
I have implemented:
	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		return array(
			'author'=>array(self::BELONGS_TO, 'User', 'authorId'),
			'comments'=>array(self::HAS_MANY, 'Comment', 'postId',
				'order'=>'??.createTime'),
			'tagFilter'=>array(self::MANY_MANY, 'Tag', 'PostTag(postId, tagId)',
				'together'=>true,
				'joinType'=>'INNER JOIN',
				'condition'=>'??.name=:tag'),
		);
	} 
Is there something else I should be doing?
Thanks again for all your help, much appreciated
Mungo
         
        
           
         
            
       
      
        
          
          
            qiang  
          
              
                March 5, 2009,  6:10pm
               
              53 
           
         
        
          If your Post table already has 'tags' column, you just need to use $post->tags to access it.
If it doesn't, you can define 'tags' relation as follows:
'tags'=>array(self::MANY_MANY, 'Tag', 'PostTag(postId, tagId)')
And then $post->tags will give you an array of Tag objects.
         
        
           
         
            
       
      
        
          
          
            Mungo  
          
              
                March 5, 2009,  6:44pm
               
              54 
           
         
        
          Ahhh… got it! That helped - thank you 
My silly error was that I had not updated the database to the new schema. (I got half way through the tutorial when the update to 1.0.3 came out!)
While my immediate problem is resolved - I am still a little confused - why have a tags field in the Post table when there is a relation to Tags there already? Is it not possible to create a field that reflects that relation?
Thanks again
Mungo
         
        
           
         
            
       
      
        
          
          
            qiang  
          
              
                March 5, 2009,  6:52pm
               
              55 
           
         
        
          That's for speed and convenience. When we display the post list, we want to be fast without the need to join two tables.
         
        
           
         
            
       
      
        
          
          
            Mungo  
          
              
                March 5, 2009,  7:18pm
               
              56 
           
         
        
          Interesting!
I guess this is an unusual scenario as the list of tags associated with a post needs to be editable and therefore any of the other form elements are not suitable. Unless there was some kind of dynamic select perhaps.
I don't have the time to look into this at the moment (deadlines looming) but I wonder if an interface similar to the Add Bookmark to Delicious would be a good way to manage tags.
Anyway - problem solved - thank you again for all your help
Mungo