[Module] Ycm - Yii Content Management Module

Are you still having the same problem? What kind of setup are you using? I can’t reproduce that kind of behavior in any environment.

Edit: what happens if you remove ‘urlFormat’=>‘path’ from urlManager in main configuration and go to url http://mydomain/?r=ycm ?

Yeah, after couple of hours of experiments, I found out, that "unsafe" is solver for that problem.

The "required" is HTML attribute, from bootstrap. If your new version function is able to override any options, then that attribute can be added already. :slight_smile:

Yes, I’m having serious problems, as that is only thing left for me to solve, cause tomorrow morning, I will teach client to use ycm, to manage stuff in page, and pager is broken.

My configuration is as follows:


'urlManager'=>array(

	'urlFormat'=>'path',

	'showScriptName'=>false,

	'caseSensitive'=>false,

	'rules'=>array(

		'<controller:\w+>/<id:\d+>'=>'<controller>/view',

		'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

		'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

	),

),



It is default rule set.

By the way, filters work and it works well, but pager displays pages with links like:


/ycm/model/list/ycm%2Fmodel%2Flist%2Fname%2FArticle//name/Article/Article_page/2

And when filter is selected, it displays anchor link like this:


/ycm/model/list/ycm%2Fmodel%2Flist%2Fname%2FArticle//Article%5Btitle%5D/k/Article%5Bauthor_id%5D//Article%5Bdate_created%5D//Article%5Bdate_modified%5D//Article%5Barticle_section_id%5D//Article_page/2/ajax/objects-grid/name/Article

I tried to understand, how that can happen, but still, without any luck.

Hi! I installed your example. I have a question about the files. How can you manage the uploaded files? For example to remove or select an image from uploaded to insert in the field (eg logo)?

Hi Janisto , first of all great extension with all built in functionality for admin. I am new to yii and i like this very much. :D

please help me to understand that how i can use redactor in ycm to upload an image ?

Hi, if I use your module with giix module error happens when ycm try to create class from abstract.

I added this lines:




foreach ($files as $file) { 							  


$modelName=str_replace('.php','',substr(strrchr($file,DIRECTORY_SEPARATOR),1));

$class = new ReflectionClass($

if($class->isAbstract()){

continue;

}

$this->addModel($modelName);

}



line 122 YcmModule

Hi friends!

How can use multiupload image in ycm? Please, give me step-by-step manul!

Thank you!

Hello Janisto and others!

Does anybody know how to Delete attached file / image ? This is the only thing i miss much.

regs

Tom

I can not operate the filter class to TbGridView relationship!




<?php


/**

 * This is the model class for table "artigo".

 *

 * The followings are the available columns in table 'artigo':

 * @property integer $idArtigo

 * @property integer $idArea

 * @property string $titulo

 * @property string $conteudo

 * @property string $imagem

 * @property integer $ordem

 * @property string $ativo

 * @property string $datacriacao

 * @property string $dataedicao

 *

 * The followings are the available model relations:

 * @property Area $idArea0

 * @property Box[] $boxes

 */

class Artigo extends CActiveRecord

{

  /**

   * Admin variables (ycm module)

   */

  public $adminNames=array('Artigos','Artigo','Artigoss'); // admin interface, singular, plural

  /**

	 * @return string the associated database table name

	 */

	public function tableName()

	{

		return 'artigo';

	}


	/**

	 * @return array validation rules for model attributes.

	 */

	public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			//array('idArea, titulo, conteudo, imagem, ordem', 'required'),

			array('titulo, conteudo, ordem', 'required'),

			array('idArea, ordem', 'numerical', 'integerOnly'=>true),

			array('titulo, imagem', 'length', 'max'=>255),

			array('ativo', 'length', 'max'=>4),

			array('datacriacao, dataedicao', 'safe'),

			// The following rule is used by search().

			// @todo Please remove those attributes that should not be searched.

			array('idArtigo, idArea, titulo, conteudo, imagem, ordem, ativo, datacriacao, dataedicao', 'safe', 'on'=>'search'),

		);

	}


	/**

	 * @return array relational rules.

	 */

	public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			//'idArea0' => array(self::BELONGS_TO, 'Area', 'idArea'),

			'area' => array(self::BELONGS_TO, 'Area', 'idArea'),

			'boxes' => array(self::HAS_MANY, 'Box', 'idArtigo'),

		);

	}


	/**

	 * @return array customized attribute labels (name=>label)

	 */

	public function attributeLabels()

	{

		return array(

			'idArtigo' => 'Id',

			'idArea' => 'Area',

			'titulo' => 'Título',

			'conteudo' => 'Conteúdo',

			'imagem' => 'Imagem',

			'ordem' => 'Ordem',

			'ativo' => 'Ativo',

			'datacriacao' => 'Data de Criação',

			'dataedicao' => 'Data de Edição',

		);

	}


	/**

	 * Retrieves a list of models based on the current search/filter conditions.

	 *

	 * Typical usecase:

	 * - Initialize the model fields with values from filter form.

	 * - Execute this method to get CActiveDataProvider instance which will filter

	 * models according to data in model fields.

	 * - Pass data provider to CGridView, CListView or any similar widget.

	 *

	 * @return CActiveDataProvider the data provider that can return the models

	 * based on the search/filter conditions.

	 */

	public function search()

	{

		// @todo Please modify the following code to remove attributes that should not be searched.


		$criteria=new CDbCriteria;


		$criteria->compare('idArtigo',$this->idArtigo);

		$criteria->compare('idArea',$this->idArea);

		$criteria->compare('titulo',$this->titulo,true);

		$criteria->compare('conteudo',$this->conteudo,true);

		$criteria->compare('imagem',$this->imagem,true);

		$criteria->compare('ordem',$this->ordem);

		$criteria->compare('ativo',$this->ativo,true);

		$criteria->compare('datacriacao',$this->datacriacao,true);

		$criteria->compare('dataedicao',$this->dataedicao,true);


		return new CActiveDataProvider($this, array(

			'criteria'=>$criteria,

		));

	}


	/**

	 * Returns the static model of the specified AR class.

	 * Please note that you should have this exact method in all your CActiveRecord descendants!

	 * @param string $className active record class name.

	 * @return Artigo the static model class

	 */

	public static function model($className=__CLASS__)

	{

		return parent::model($className);

	}

  /**

   * Config for attribute widgets (ycm module)

   *

   * @return array

   */

  public function attributeWidgets()

  {

    return array(

      array('idArtigo','textField'),

      array('idArea','chosen'),

      array('titulo','titulo'),

      array('conteudo','wysiwyg'),

      array('imagem','image'),

      array('ordem','textField'),

      /*array('ativo','chosen'),

      array('datacriacao','datetime'),

      array('dataedicao','datetime'),*/

    );

  }

  /**

   * Select choices for field3 (ycm module)

   *

   * @return array

   */

  public function idAreaChoices()

  {

    return CHtml::listData(Area::model()->findAll(), 'idArea', 'nome');

  }

  /**

   * Config for TbGridView class (ycm module)

   *

   * @return array

   */

  public function adminSearch()

  {

    return array(

      'columns'=>array(


        'idArtigo',

        //'idArea',

        array(

          'header'=>'idArea',

          //'filter'=>CHtml::activeTextField($this->area, 'nome', $htmlOptions=array( )),

          //'filter'=>CHtml::activeInputField('text', $data->area, $data->area->nome, $htmlOptions=array( )),

          //'filter'=>CHtml::textField('Artigo[area->nome]','', $htmlOptions=array( )),

          //'filter'=> CHtml::listData(Area::model()->findAll(), 'idArea', 'nome'),

          //'filter'=>CHtml::inputField( 'text', $data, $data->area->nome, $htmlOptions=array( )),

          'filter'=>CHtml::dropDownList('Sessão', '', $this->idAreaChoices(),$htmlOptions=array( )),

          //'type'=>'html',

          //'value'=>'CHtml::link($data->area->nome, $url="index.php?r=ycm/model/update&name=Area&pk=$data->idArea", $htmlOptions=array( ))'

          'value'=>'($data->area) ? $data->area->nome : "Nenhuma Area"'

        ),

        'titulo',

        'conteudo',

        /*array(

          'name'=>'ativo',

          'value'=>'$data->ativo==1 ? CHtml::encode("Yes") : CHtml::encode("No")',

          'filter'=>array(1=>'Yes',0=>'No'),

        ),*/

        array(

          'header'=>'Imagem',

          'filter'=>'',

          'type'=>'html',

          'value'=>'(!empty($data->imagem))?CHtml::image(Yii::app()->assetManager->publish("uploads/artigo/imagem/$data->imagem"),"",array("class"=>"thumbnail image")):"sem imagem"'

        ),

        'ordem',


        /*array(

          'name' => 'datacriacao',

          'value' => 'date("d.m.Y H:i:s",strtotime($data->datacriacao))',

        ),*/

        /*array(

          'name' => 'dataedicao',

          'value' => 'date("d.m.Y H:i:s",strtotime($data->dataedicao))',

        ),*/

      ),

    );

  }

}



Hello Janisto,

Thank you for your extension, I love it.

I have two questions:

  • I wonder if there is a way to set options for wysywyg field redactor, I want to introduce the ‘replaceDivs’=>false options, I know I can achieve this in the core of your module, but I prefer to use a more elegant solution.

  • In v1.1.3 readme.txt you say:

"Options to disable create, update and/or delete actions for a model"

How can achieve this?

I’m so sorry if my questions are very basic and thank you very much again.


Ok, so I edit my post in order to help someone, sometime, somewhere.

  1. For now the only way to achieve this is set the options in the redactor.js file, located in /module/ycm/extensions/redactor/assets/js/ folder

You can set any value, in my case I set


replaceDivs: false

in line 247

I’m thinking in a best solution bur for now this work for me.

  1. If you wan’t to disable the create, update and/or delete actions for a model you only need to set

    public $hideCreateAction=true;

    public $hideUpdateAction=true;

    public $hideDeleteAction=true;

in the model (for example in the variables declaration section).