Welcome Guest, Not a member yet? Register   Sign In
PyroCMS v0.9.7.4 - an open-source modular general purpose CMS

[eluser]Yorick Peterse[/eluser]
[quote author="Phil Sturgeon" date="1248104806"]Exactly. How do we add a widget area into a page?[/quote]

Specify which areas are available for the current template (so you can choose one of them in the backend):

areas.json (stored in the current template)

Code:
{"area1","area2"}

In your template, add something like the following :

Code:
<div id="sidebar">
    &lt;?php $this->widgets->load('area1'); ?&gt;
</div>

That will load all widgets for area 1

[eluser]Phil Sturgeon[/eluser]
How about adding a widget area for a new module I have created, or for adding to a new page? A theme designer wont know EVERYTHING about all modules to ever be constructed.

[eluser]Yorick Peterse[/eluser]
He doesn't need to know that. A theme designer will only specify the areas that are available and their locations, that's it. It might be better if I'll explain it in real time, perhaps time for another fancy chat session ?

[eluser]ray73864[/eluser]
there will be widgets that i want on every page too, going back to my 'Opening Hours' idea, i might have a widget on the side of the screen that shows an 'opening hours' widget which defaults to showing just the pharmacy's opening hours, and it might be that the widget is showing nothing more than the page in the database called 'opening hours', or it might be a widget belonging to a module (such as the news module) where the module itself has the main view page for showing all news items and the widget just shows the top 5 for instance.

[eluser]ray73864[/eluser]
Soooo, here's my idea of widgets, and please oh please do criticise and all that, comments very much welcome Smile

Anyway, the way i see the widget system working is sort of like the modules system and the navigation module combined. You create a module, and then define in that module (in a similar way to the details.xml file) a 'widget.xml' file, which basically says what version the different widgets are, what the view files are for those widgets, etc...

Then, in a special new 'widget' module, it goes through and lists all the widgets available on the CMS, then, like navigation, you have special widget areas on the page, eg. header, footer and sidebar. You use the widget module to activate/deactivate widgets and also assign them to different areas on the page.

This way, you could have a news ticker on the top of the page coming from the news module, and at the same time display the top 5 news articles in the sidebar underneath the navigation coming from another widget in the news module.

When a module is deleted, the widgets that it has go with it, just like what happens when you delete a module and it disappears from the admin panel.

[eluser]Yorick Peterse[/eluser]
[quote author="ray73864" date="1248182768"]Soooo, here's my idea of widgets, and please oh please do criticise and all that, comments very much welcome Smile

Anyway, the way i see the widget system working is sort of like the modules system and the navigation module combined. You create a module, and then define in that module (in a similar way to the details.xml file) a 'widget.xml' file, which basically says what version the different widgets are, what the view files are for those widgets, etc...

Then, in a special new 'widget' module, it goes through and lists all the widgets available on the CMS, then, like navigation, you have special widget areas on the page, eg. header, footer and sidebar. You use the widget module to activate/deactivate widgets and also assign them to different areas on the page.

This way, you could have a news ticker on the top of the page coming from the news module, and at the same time display the top 5 news articles in the sidebar underneath the navigation coming from another widget in the news module.

When a module is deleted, the widgets that it has go with it, just like what happens when you delete a module and it disappears from the admin panel.[/quote]

The system already works like that, with the only exception being that it's using json files, rather than XML.

[eluser]ray73864[/eluser]
so is there a new 'widget module' then, or does everything, such as placement of widget and all have to be done in the json file?

doing it in the json file kinda makes the assumption that someone has to know how a json file looks and works in order to set it up correctly.

perhaps we could have full documentation on the widgets including complete examples of how to make it all work, the stuff on the widgets page is a little vague (at least how i perceive it).

ahh, i see it is a work in progress. also, the only functionality that i forsee the widgets system lacking is that you can't control what widgets go in what section of the page, well, you could by replacing the foreach with something like

Code:
$this->yummy->run(news['name']);

perhaps changing it so that instead of calling the 'yummy->widgets' variable directly, you call a function to get all the widgets for a certain area, eg:

Code:
$widgets = $this->yummy->getWidgets('header');

// Loop through each widget and execute it
foreach($widgets as $widget)
{
      // Execute the current widget
      $this->yummy->run($widget['name']);
}

would load all the 'header' widgets into the header area of the page.

[eluser]Phil Sturgeon[/eluser]
Yorick, I realised I was being a bit silly with my request earlier of adding widget areas into a page. Thats clearly not any use if we can call widgets directly.

Lets have two library functions:

$this->widget->area('some-widget-area');

Loads an entire widget area and stops developers needing to use that foreach loop every time.

$this->widget->run('some-widget', TRUE/FALSE);

Runs a widget with default behaviour being output the content directly to output class. If TRUE, return the output as a string.

Then, we have a winner! This has lovely clean syntax and will mean we can have pre-defined theme widget areas, and end users can plonk widgets directly into a new page they create through the WYSIWYG.

Sound good?

[eluser]Yorick Peterse[/eluser]
[quote author="Phil Sturgeon" date="1248196992"]Yorick, I realised I was being a bit silly with my request earlier of adding widget areas into a page. Thats clearly not any use if we can call widgets directly.

Lets have two library functions:

$this->widget->area('some-widget-area');

Loads an entire widget area and stops developers needing to use that foreach loop every time.

$this->widget->run('some-widget', TRUE/FALSE);

Runs a widget with default behaviour being output the content directly to output class. If TRUE, return the output as a string.

Then, we have a winner! This has lovely clean syntax and will mean we can have pre-defined theme widget areas, and end users can plonk widgets directly into a new page they create through the WYSIWYG.

Sound good?[/quote]
Omg you muppet, that's how the library works (with the exception of the true/false part).

@ray

The only thing that's stored in a json file is a list of available areas and widget information (author, description, etc). The rest goes in a database (such as the actual widget content).

I'll post a working demo soon, but first I really, really need to continue cleaning my room. Tongue

[eluser]Phil Sturgeon[/eluser]
Ahh, well thats alright then. We need a way to return it as a string so it can be loaded within HelpfulParser, and therefore used in pages.




Theme © iAndrew 2016 - Forum software by © MyBB