Giter Club home page Giter Club logo

Comments (19)

sandeepone avatar sandeepone commented on September 18, 2024

Insert directly into db:

                        $widget = ORM::factory('widget');
                        $widget->name = 'blog/recent'; //name must be unique
                        $widget->title = 'Recent Blogs';
                        $widget->module = 'blog';
                        $widget->save();

Create a class extends widget class:

classes/widget/blog.php

class Widget_Blog extends Widget {

    public function info()
    {
    }
    
    public function form()
    {
    }

    public function save( array $post )
    {
        //Message::debug( Debug::vars($post) );
    }

    public function delete( array $post )
    {
    }
    
    public function render()
    {
        switch($this->name)
                {
                        case 'recent':
                                return $this->recent_blogs($this->widget);
                        break;
                case 'popular':
                                return $this->blog($this->widget);
                        break;
                        default:
                                return;
                }
    }
    
        public function recent_blogs($widget)
        {
                // Dont show the widget on edit or delete actions.
        if( Request::current()->action() == 'edit' OR Request::current()->action() == 'delete' )
            return false;

            $blogs = ORM::factory('blog')
                    ->where('status', '=', 'publish')
                    ->order_by('created', 'DESC')

    
        return View::factory('blog/widget/list')->set('posts', $blogs);
        }

}

from cms.

sandeepone avatar sandeepone commented on September 18, 2024

For static widgets, you can add directly from admin/widgets/add

from cms.

sergeyklay avatar sergeyklay commented on September 18, 2024

This exists in Wiki?

from cms.

sandeepone avatar sandeepone commented on September 18, 2024

need to add in wiki. Thanks for pointing it. Same thing with ACL as well.

from cms.

sergeyklay avatar sergeyklay commented on September 18, 2024

assign me please (with needed rights)

from cms.

sandeepone avatar sandeepone commented on September 18, 2024

Let me check about rights on how to assign rights etc..

from cms.

sandeepone avatar sandeepone commented on September 18, 2024

GitHub Wikis are the simplest way to let others contribute content. Any GitHub user can create and edit pages to use for documentation, examples, support or anything you wish.

from cms.

sergeyklay avatar sergeyklay commented on September 18, 2024

@sandeepone I think I'm having problems with the widgets ... Can you give a more detailed example?

from cms.

sandeepone avatar sandeepone commented on September 18, 2024

Please explain your problem, show the code.. it would be easy for me

from cms.

sergeyklay avatar sergeyklay commented on September 18, 2024

Here is the order of my actions:

1. Inserted directly into db:

$widget = ORM::factory('widget');
$widget->name = 'post/recent';
$widget->title = 'Recent Postss';
$widget->module = 'post';
$widget->save();

2. Created a class /modules/gleez/classes/widget/post.php with the following content:

<?php defined('SYSPATH') OR die('No direct access allowed.');

class Widget_Post extends Widget {

  public function info(){}
  public function form(){}
  public function save(array $post){}
  public function delete(array $post){}

  public function render()
  {
    switch($this->name)
    {
      case 'recent':
        return $this->get_recent_posts($widget);
      break;
      default:
        return;
    }
  }

  public function get_recent_posts($widget)
  {
    if(Request::current()->action() == 'edit' OR Request::current()->action() == 'delete')
    {
      return FALSE;
    }

    $posts = ORM::factory('post')
            ->where('status', '=', 'publish')
            ->order_by('created', 'DESC');

    return View::factory('widgets/posts/list')
                ->set('posts', $posts);
  }

}

3. Created a view /modules/gleez/views/widgets/post/list.php:

<?php defined("SYSPATH") OR die("No direct script access.");?>

<p>
  Hello world! <!-- nothing happens -->
</p>
<?php 
  echo Debug::vars(posts); // nothing happens
?>

4. Go to address localhost/admin/widgets
5. Enabled widget (yes, there, in the list of widgets, it appears)

nothing happens...

P.S. I use my personal theme, but it is designed in the likeness fluid with small changes. The log journal there is nothing worthy of attention.

from cms.

sergeyklay avatar sergeyklay commented on September 18, 2024

so, that with this? :(

from cms.

sandeepone avatar sandeepone commented on September 18, 2024

Sorry for being late replies. I returned from vacation today. The code seems correct, i'll run the code and test to see why it's not working.

@sergeyklay please send any important pull requests, i'm working on pushing lot of changes, so manual merge is needed.

from cms.

sergeyklay avatar sergeyklay commented on September 18, 2024

I really hope that we will solve this problem..

from cms.

sandeepone avatar sandeepone commented on September 18, 2024

Sorry for delaying.. Doing some code cleanup.. will do it today itself..

from cms.

sandeepone avatar sandeepone commented on September 18, 2024

Hope the issue fixed. Can i close this here??

from cms.

sergeyklay avatar sergeyklay commented on September 18, 2024

Yes, Thanks! For edit/update the documentation on the wiki, we will create a separate issue

from cms.

sergeyklay avatar sergeyklay commented on September 18, 2024

@sandeepone You can close this here. I'm created https://github.com/gleez/cms/wiki/Widgets

also see https://github.com/gleez/cms/wiki

from cms.

sergeyklay avatar sergeyklay commented on September 18, 2024

what with this?

from cms.

sandeepone avatar sandeepone commented on September 18, 2024

Good job. 👍

from cms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.