Beta 3

General questions about CMSimple
Post Reply
PatrikGC
Posts: 117
Joined: Wed Jun 18, 2008 9:34 am

Beta 3

Post by PatrikGC » Tue Sep 15, 2009 5:59 pm

Good software ! I like it so !

About the beta 3 version :
- Few documentation about plugins.
- How to merge 2 cells in the editor ?
- How to list the images when inserting, without writing the url ?
- How to write a plugin for XH ? (very good question !)

Otherwise, great job, congratulations and bravo!

Gert
Posts: 3078
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: Beta 3

Post by Gert » Tue Sep 15, 2009 7:08 pm

PatrikGC wrote:- Few documentation about plugins.
Hallo Patrik, there is a FAQ-Section under developement:

http://www.cmsimple-xh.de/faq/ - the translators are working.

CMSimple_XH versions "beta x.x" are for testing, for Experts. We will make some documentation before publishing CMSimple_XH 1.0 ;)
PatrikGC wrote:- How to write a plugin for XH ? (very good question !)
You can make Plugins for CMSimple_XH like Plugins for CMSimple classic. Some hints for CMSimple_XH you will find here:

http://www.cmsimple-xh.de/english/?Developers-Area
Gert Ebersbach | CMSimple | Templates - Plugins - Services

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: Beta 3

Post by Holger » Tue Sep 15, 2009 7:18 pm

Hi Patrik!
PatrikGC wrote:- How to merge 2 cells in the editor ?
Mark the two tablecells, open the context-menu with a right-click, select cells -> merge cells
PatrikGC wrote:- How to list the images when inserting, without writing the url ?
Open the "Insert Image" dialog with a click on it's button, then press the "Browse server" button to open the Filebrowser in a new window. Here you can see a list with a preview of all your images in the /images folder. A click on a filename will insert the image into your content.
You can also upload and delete images with this filebrowser.

Have fun :) and thanks for posting your hints.

Holger

johnjdoe
Posts: 571
Joined: Tue May 20, 2008 6:32 am

Re: Beta 3

Post by johnjdoe » Wed Sep 16, 2009 6:16 am

PatrikGC wrote:- How to write a plugin for XH ? (very good question !)
And here is a brand new plugin example: http://www.cmsimplewiki.com/doku.php/plugins/example

Martin
Posts: 346
Joined: Thu Oct 23, 2008 11:57 am
Contact:

Re: Beta 3

Post by Martin » Wed Sep 16, 2009 12:05 pm

Bonjour Patrick,

I guess the tutorial johnjdoe pointed to helped a lot. It is a really nice one. Here is some additional information on how to make use of the new pluginloader's (that is already shipped with cmsimple_xh) api to the page specific data. They are stored in the file pagedata.php within the content folder. At the top of it you will find a list of the available data fields.

Reading: The informations about the current page can be accessed via the global variable $pd_current. It holds an array using the data fields as keys. (e.g. $pd_current['last_edit'] contains the date of the last edit of the current page.) To gather all pages just use $pd_router->find_all();. There are some more functions to select and sort the page infos - have a look at plugins/pluginloader/pagedata/page_data_router.php

Writing: If your plugin needs to add its own data to the page informations, let's say as "my_test_field", just add this line:

Code: Select all

$pd_router -> add_interest('my_test_field'); 
Create a function that returns the html-form you want to add: This function
  • has to be named like your plugin, extended by '_view' and expects the infos of the current page as parameter. E.g.:

    Code: Select all

    function my_test_plugin_view($page){
        //code that generates and returns your form
    } 
  • This form has to contain a hidden field named "save_page_data" - and of course the input fields for your data (e.g. <input type="text" name="my_test_field" value="'. $page['my_test_field'] .'" />)
  • Store this function in a file that is named just like the function in the root folder of your plugin. (E.g. plugins/my_test_plugin/my_test_plugin_view.php)
Add it to the row of tabs above the editor like this:

Code: Select all

$pd_router -> add_tab('label of the tab', $pth['folder']['plugins'].'my_test_plugin/my_test_plugin_view.php'); 
To get it all together, here is a short example: A plugin that adds some additional information - might be an excerpt or something - to the pages and shows a list of this excerpts, sorted by the date of the last edits. Something like this would have been hard work before, with the new pluginloader it can be done in about 30 lines of code:

Create the folder "plugins/my_test_plugin", add the files "index.php" and "my_test_plugin_view.php" to it.

index.php:

Code: Select all

<?php
if(!defined('PLUGINLOADER_VERSION')){     // make sure an appropriate pluginloader is installed
    die('Plugin '. basename(dirname(__FILE__)) . ' requires a newer version of the Pluginloader. No direct access.');
}
$pd_router -> add_interest('my_test_field');
$pd_router -> add_tab('My test', $pth['folder']['plugins'].'my_test_plugin/my_test_plugin_view.php');
$my_pages_array = $pd_router->find_all();
// o.k. - this sorting has nothing to do with the new function
// - I just could not resists to do something with the page data
$sorter = array();
$keys = array();
foreach($my_pages_array as $index => $data){
    $sorter[$index] = $data['last_edit'];
    $keys[$index] = $index;
}
array_multisort($sorter, SORT_DESC, $keys, SORT_DESC, $my_pages_array);
// prepare the output
$my_output = '<ul>';
foreach($my_pages_array as $key => $params){
    $key = $keys[$key];
    $my_output .= '<li><a href="'.$sn.'?'. $u[$key].'">'.$h[$key].'</a>:';
    $my_output .= $params['my_test_field'].'</li>';
}
$my_output .= '</ul>';
// this will add the list on top of your pages
// probably you want to echo the $my_output somewhere in the template instead
$o .= $my_output;
?>
my_test_plugin_view.php:

Code: Select all

<?php
function my_test_plugin_view($page){
    global $sn, $su;
    $view = '<form action="'.$sn.'?'.$su.'" method="post">';
    $view .= "\n\t".tag('input type="text" size="50" name="my_test_field"  value="'. $page['my_test_field'].'"');
    $view .= "\n\t".tag('input name = "save_page_data" type = "hidden"');
    $view .= "\n\t".tag('input type="submit"').tag('br');
    $view .= "\n".'</form>';
    return $view;
}
?>
That's all! It is a working plugin. Everything else, about configuration and language files, has not changed at all and was described in the tutorial better than I could ....

Regards
Martin
Last edited by Martin on Wed Sep 16, 2009 7:37 pm, edited 1 time in total.

PatrikGC
Posts: 117
Joined: Wed Jun 18, 2008 9:34 am

Re: Beta 3

Post by PatrikGC » Wed Sep 16, 2009 5:25 pm

I thank you all !

Merge cells : ok for the right clic, I didn't know it.
Pictures : I must resize the opening window for seeing the picture files inside. And after, I can insert a picture in my text.
Plugins : I thank you all for the links, I will go and see them.
Martin : Great thanks for the small tutorial !

And now, as we say it in french : yapluka :D
yapluka -> il n'y a plus qu'à... -> we must do it now / let's go

Post Reply