Yii Framework Forum: [Module] Ycm - Yii Content Management Module - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[Module] Ycm - Yii Content Management Module

#21 User is offline   janisto 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 64
  • Joined: 30-March 11
  • Location:Helsinki, Finland

Posted 08 May 2013 - 06:00 AM

View PostDeele, on 06 May 2013 - 06:57 AM, said:

And another problem I noticed just now: pager links are broken. It is showing "http://mydomain/ycm/model/list/ycm%2Fmodel%2Flist%2Fname%2FArticle//name/Article/Article_page/2" while inside "http://mydomain/ycm/model/list/name/Article". Dunno where to start looking for problem...

EDIT: In reponse to clicking on pager page with mentioned url, there is an error, that ModelController in line 130 received an empty string from $_GET[get_class($model)], that can't be iterated with foreach. If I add "&& !empty($_GET[get_class($model)])", it still doesn't work, it returns partial render of that table in response, but client side JS/Ajax can't handle it.

EDIT2: Pager and column header links broken. Only edit/delete and filter fields usable.


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 ?
0

#22 User is offline   Deele 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 02-May 13
  • Location:Riga, Latvia

Posted 08 May 2013 - 01:04 PM

View Postjanisto, on 08 May 2013 - 05:53 AM, said:

Checkout the development version: https://github.com/janisto/yii-ycm/

Now you can override options in all form widgets.
For example:
	public function attributeWidgets()
	{
		return array(
			array('fieldName','textField','class'=>'span6','placeholder'=>'Type something…','hint'=>'Lorem Ipsum','disabled'=>'disabled'),

		);
	}


If you want a required field, then you must define that in the rules:
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('fieldName', 'required'),
		);
	}


"image" and "file" type fields must be defined "unsafe" in the rules. Then update should work properly.

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. :)

View Postjanisto, on 08 May 2013 - 06:00 AM, said:

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 ?

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.
0

#23 User is offline   Timz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 13-March 13

Posted 18 May 2013 - 04:24 AM

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)?
0

#24 User is offline   nick007 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 13-August 13

Posted 19 August 2013 - 05:19 AM

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 ?
0

#25 User is offline   mitch3182 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 04-October 12

Posted 24 October 2013 - 07:21 AM

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
0

#26 User is offline   kanet 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 22-November 13

Posted 22 November 2013 - 03:32 PM

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

Thank you!
0

#27 User is offline   tomo31 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 13-December 13

Posted 13 December 2013 - 05:58 AM

Hello Janisto and others!

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

regs
Tom
0

#28 User is offline   acostaC 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 04-March 13

Posted 27 January 2014 - 12:43 PM

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))',
        ),*/
      ),
    );
  }
}

0

#29 User is offline   willowl 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 17-December 10

Posted 18 February 2015 - 02:56 PM

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.

2. 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).
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • 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