Yii 1.1: simplecms

Simple cms provide a simple div wich content can be updated in-place
8 followers

This is not a real cms, it cannot create new pages and so on.

It is useful in an application that is 90% dynamical, with content that cannot be managed with any cms, and a 10% of text.

This extension supply a simple div with text. The text can be managed in-place with a dialog box with a text area (you can easily enhance using any of the WYSIWYG in extension)

Requirements

Yii 1.5 or higher.

Usage

Add this table to the database:

CREATE TABLE IF NOT EXISTS `content` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `label` varchar(50) CHARACTER SET utf8 NOT NULL,
  `text` longtext CHARACTER SET utf8 NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `label` (`label`)
)  ;

Extract the zip file in extension, then configure the main config as follows:

<?php
 
return array(
    // autoloading model and component classes
    'import'=>array(
        'application.models.*',
        'application.components.*',
        'application.extensions.simpleCMS.*',
    ),
 
    // application components
    'components'=>array(
        'user'=>array(
            'class'=>'ZWebUser',
        ),
);

Add the directoty to the paths and we chagne the user class. We need a user class with a method that says wether a user is admin (not all application uses RBAC).

Now add this line in SiteController:

<?php
 
class SiteController extends Controller
{
    public function actions()
    {
        return array(
            'updateCms'=>'ActionUpdateCms',
        );
    }   
}

This line add an action to the SiteController for answer to the widget.

The trick is done! You can create your box in this way:

<?php $this->widget('simpleCMS', array('label'=>'textId'))?>

Total 9 comments

#4630 report it
markux at 2011/07/27 10:01am
problem on linux

on linux (case sensitive file system) I've replaced all simpleCMS and SimpleCms to SimpleCMS, because yii not find it.

PS: I've integrated CKeditor with simplecms and it's not easy (problem with jquery ui modal and with id Content_text not unique).

#3064 report it
zaccaria at 2011/03/11 07:24am
update

Hi!

I have update the cms class for implement following this guide.

If anyone notice some more error, please ask here!

#3029 report it
zaccaria at 2011/03/09 03:42am
ops

By bad, I forgot the wysiwyg textarea.

I will update this wiki in the next days using this approach, wich is compatible with opera.

#3021 report it
Karzi at 2011/03/08 07:26am
Working now

Works with the following:

<?php echo CHtml::activeTextArea($model,'text'); ?>
#3016 report it
Karzi at 2011/03/08 04:58am
Errors

I'm trying to implement this extension and there's been a few things I've needed to change, but now I'm stuck with an error on line 44 on the file "div.php", which is:

<?php echo FHtml::CLTextArea($model,'text'); ?>

Changing this to CHtml didn't work and I couldn't find a CLTextArea method from YII class references either.

Any suggestions?

#2908 report it
zaccaria at 2011/02/25 01:59am
@philippfrenzel

HI!

Thank you for kind signalation, I updated the article accordigly.

About the user role check, I agree with you that this is the standard way, I implemented differenty in order to give an example of custom implementation, to use in scenario in wich there is no rbac but just a boolean fields in table user

(wich are the majority of my application, btw)

#2905 report it
PinkBrainPlan at 2011/02/24 04:48pm
Paths

Hi,

in your paths you use extension instead of the autogenerated extensions _ "s" is different, so I had to fix it manually. Hopes this saves time for others to implement...

And I changed the user role check to Yii:app()->user->checkAccess('admin'); What worked fine for me;)

cheers Phil

#2851 report it
zaccaria at 2011/02/16 08:43am
re: name

This widget is meant to be used in context in wich a cms is too much or is not appliable.

Atually it gives the possibility of manage content, so it is by definition a content managment system, but is much simplier than any cms, as it is not providing create page features.

That's the reason of the name: too simple for cms, but anyway cms

#2850 report it
Maurizio Domba Cerin at 2011/02/16 07:49am
name?

As you wrote on the first line, this is not a CMS... so why call it simpleCMS?

Leave a comment

Please to leave your comment.

Create extension
Downloads