Yii Framework Forum: [MODULE] p3widgets - Yii Framework Forum

Jump to content

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

[MODULE] p3widgets Phundament 3 - CMS Rate Topic: -----

#1 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 561
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 31 May 2011 - 06:39 PM

Phundament 3 - Widgets

P3WidgetsModule provides basic Content Management System (CMS) functionality through a widget container for frontend-editing and a backend for managing widget properties and content.

A widget container tags its contents (widgets) by its id, the current controller and action and optionally also by a request parameter.

When you edit a widget you can specify its type (see config value modules[p3widgets].params[widgets]), its attributes by editing them with a built-in JSON editor and its content by editing it with a built-in ckeditor.

Database schema setup is done easily with yiic migrate.

Installation, Download, etc: http://www.yiiframew...sion/p3widgets/
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#2 User is offline   mc.aser 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 06-March 09

Posted 07 June 2011 - 01:47 AM

I hooked up the widget, but the set does not come out. I added

'widgets' => array(
     'CWidget' => 'Basic Widget',
     'zii.widgets.CMenu' => 'Menu bar'
)


In the widgets added entry
Alias	zii.widgets.CMenu
Properties	{"items":{"":{"label":"Home","url":"http://strat.ua"}}}
Content	<p> ffghfghfghgfh</p>


Text [b] ffghfghfghgfh [/ b] conclusions, as there is no menu. In what may be the problem?
Thanks!
0

#3 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 561
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 07 June 2011 - 07:20 AM

Hi mc.aser,

I do not have fix right now, but at least I found the problem.

The problem is, that I am using beginWidget() and endWidget() to render the widget with its contents.
But somehow I also have to call the run()-method of the widget to display the CMenu - this should be done by endWidget(), but it does not work.

CWidget, line 144:
	/**
	 * Executes the widget.
	 * This method is called by {@link CBaseController::endWidget}.
	 */
	public function run()
	{
	}


I will investigate that...


Thanks for your feedback & best regards,
schmunk
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#4 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 561
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 07 June 2011 - 07:41 AM

Could you check this fix?
https://github.com/s...57c2ede8ceb9366

Simply exchange the file /protected/modules/p3widgets/components/P3WidgetContainer.php
https://github.com/s...etContainer.php
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#5 User is offline   mc.aser 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 06-March 09

Posted 07 June 2011 - 12:48 PM

View Postschmunk, on 07 June 2011 - 07:41 AM, said:

Could you check this fix?
https://github.com/s...57c2ede8ceb9366

Simply exchange the file /protected/modules/p3widgets/components/P3WidgetContainer.php
https://github.com/s...etContainer.php


I Fixed this by adding $properties in
$this->controller->beginWidget($class, $properties); 
.
I looked you did too:). It works.

Still do not understand how it works requestParam.

Yes, another change to the

$criteria->condition = '(controllerId = '' OR controllerId = :controllerId) AND (actionName = '' OR actionName = :actionName) AND containerId = :containerId';


This allows the unit to all actions of the controller or the entire site in general, such units as the main menu, the advertising zone or follow tweeter.

Thank you for your work!
0

#6 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 561
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 07 June 2011 - 05:06 PM

View Postmc.aser, on 07 June 2011 - 12:48 PM, said:

I Fixed this by adding $properties in
$this->controller->beginWidget($class, $properties); 
.
I looked you did too:). It works.

:)

View Postmc.aser, on 07 June 2011 - 12:48 PM, said:

Still do not understand how it works requestParam.

In the Yii app skeleton you have the about page, which is rendered by the site controller, action page and request parameter view ($_GET['view']).
If you add another view test you can access it with ?r=site/page&view=test.
If you would now not varyByRequestParam view containers in both views would display the same widgets (if they have have the same id).
With a CMS for example you would have a CmsController and an id for every page and you would use the same template view for different pages and then you'd have to varyByRequestParam to select the correct widgets.
Maybe this parameter could also be an array to handle multiple values, but this would make selecting the records more difficult.

View Postmc.aser, on 07 June 2011 - 12:48 PM, said:

Yes, another change to the

$criteria->condition = '(controllerId = '' OR controllerId = :controllerId) AND (actionName = '' OR actionName = :actionName) AND containerId = :containerId';


This allows the unit to all actions of the controller or the entire site in general, such units as the main menu, the advertising zone or follow tweeter.

Yesss! You got it dude! :D That's very basic part of the concept.

I had that in Phundament 2, will be implemented soon ;)


Would be cool to see you on GitHub with a fork!
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#7 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 561
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 16 June 2011 - 09:10 AM

Demo updated: http://demo.phundament.com/3.0-dev
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#8 User is offline   peili 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 28-August 10
  • Location:Germany - Munich

Posted 08 November 2011 - 12:50 PM

JSON Editor is a good way if you know alle the Widget-Attributes. However most of my users and customers don't know all attributes.
So i added a form. This form has to be in the widget Folder with the same name as the widget + "Form". So "BasicWidget" -> "BasicWidgetForm".
The Form is dynamically updating when you choose a different Widget.

I can upload an Screencast if someone is interested.

Here is the code:

../views/widget/_form.php (You need to enable JQuery ) line 0:
<script type="text/javascript">
    $(document).ready(function() {
        $("#formBox").load("<?php echo $this->createUrl("GetForm"); ?>?form=" +
            $("#Widget_alias :selected").val() + "&id=<?php echo $model->id ?>" );
        $("select").change(function () {
            $("#formBox").load("<?php echo $this->createUrl("GetForm"); ?>?form=" +
                $("#Widget_alias :selected").val() + "&id=<?php echo $model->id ?>" );
        });
    });

</script>  


Somewhere in the form-container:
    <div id="formBox">


    </div> 


WidgetController
/**
     * Updates a particular model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id the ID of the model to be updated
     */
    public function actionUpdate($id) {
        $model = $this->loadModel($id);

        // Uncomment the following line if AJAX validation is needed
        // $this->performAjaxValidation($model);

        if (isset($_POST['Widget'])) {
            $model->attributes = $_POST['Widget'];
            if ($_POST['Form'])
                $model->properties = json_encode($_POST['Form']);
            
            $criteria = new CDbCriteria();
            $criteria->params = array(
                ':controllerId' => $model->controllerId,
                ':actionName' => $model->actionName,
                ':containerId' => $model->containerId,
                ':rank' => $model->rank,
            );
            $criteria->condition = 'actionName = :actionName AND containerId = :containerId AND controllerId = :controllerId AND rank = :rank';
            if ($model->save()) {
                $this->redirect(array('view', 'id' => $model->id));
            }
        }
        $this->render('update', array(
            'model' => $model
                ), false, true);
    }


And add this function to WidgetController:
    public function actionGetForm($id) {
        if($id){
            $properties = json_decode($this->loadModel($id)->properties);
        }
        $form = $_GET['form'] . "Form";
        if ($this->getViewFile($form)) {
            $this->renderPartial($form,array('properties'=> $properties));
        } else {
            return true;
        }
    }


Then you can add form to your Widget
Exampe BasicWidgetForm
<fieldset class="no-border">
    <label for="Form[events_headline]">Überschrift</label>
    <input name="Form[events_headline]" id="name" type="text" class="text" maxlength="" value="<?php echo $properties->events_headline ?>">

  
</fieldset>


Hopefully you get an idea. I think it is pretty useful.

Best regards,

Peili
0

#9 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 561
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 08 November 2011 - 12:55 PM

Hi peili,

thanks for your idea.
Have you seen the semi-automatic property detection in the latest release?
I had the stuff with custom forms in phundament 2, similar like you've suggested it.

I think this would be also a useful feature for Phundament 3, but had no time to code this yet.

Could you fork p3widgets on github?


Best regards,
schmunk
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
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