SkaDate / Oxwall : how to add new console item

This post describes how to add new console item with drop down of your choice into SkaDate / Oxwall software.

  • What is console?
  • Customization type: plugin development
  • Level: advanced
  • Tested on : platform version 1.7.3

Note: <code php> and </code> tags used in this post MUST NOT be used in actual .php files. Make sure to remove them.

new console item in Skadate / Oxwall software


Functions/classes/variables involved


Function: public function init()

Event manager: $eventManager->bind(‘console.collect_items’, array($this, ‘collectItems’));

Function: public function collectItems

Even hander class name: BASE_CLASS_ConsoleItemCollector

Variables: $language, $router, $item, $event->addItem .


Practical implementation


1. Create basic plugin. Official documentation here.

2. Create /classes/ directory within your plugin.

3. Create event_handler.php within /classes/ directory.

4. Introduce following functions within event_handler.php file.

<code php>

<?php

class PLUGINKEYHERE_CLASS_EventHandler
{

public function genericInit()
{
}

public function init()
{
$eventManager = OW::getEventManager();

$eventManager->bind(‘console.collect_items’, array($this, ‘collectItems’));

}

public function collectItems( BASE_CLASS_ConsoleItemCollector $event )
{

$language = OW::getLanguage();
$router = OW::getRouter();

$item = new BASE_CMP_ConsoleDropdownMenu($language->text(‘pluginkeyhere’, ‘main_console_item’));
$item->setUrl($router->urlForRoute(‘pluginkey.index’));
$event->addItem($item, 6);

$item->addItem(‘head’, array(‘label’ => $language->text(‘pluginkey’, ‘console_1′), ‘url’ => $router->urlForRoute(‘http://skadate.com&#8217;)));
$item->addItem(‘main’, array(‘label’ => $language->text(‘pluginkey’, ‘console_2′), ‘url’ => $router->urlForRoute(‘view_photo_list’)));
$item->addItem(‘main’, array(‘label’ => $language->text(‘pluginkey’, ‘console_3′), ‘url’ => $router->urlForRoute(‘desired_route_here’)));

}
}
</code>

5. Open init.php file of your plugin, introduce your event handler’s class name:

<code php>

$eventHandler = new PLUGINKEYHERE_CLASS_EventHandler();
$eventHandler->genericInit();
$eventHandler->init();

</code>

6. Within the init.php file introduce all needed routers

7. Add used language keys into langs.zip file of your plugin.


Example for personal use


We are to create a plugin that will add new console item with drop down list.

1. Create new folder on your computer. Let’s name it “customconsole

2. Create plugin.xml file within that folder. Content:

<code php>

<?xml version=”1.0″ encoding=”UTF-8″?>
<plugin>
<name>Custom Console</name>
<key>customconsole</key>
<description>this plugin adds new console item </description>
<author>Your Name</author>
<authorEmail>Your email</authorEmail>
<authorUrl>http://link.com</authorUrl&gt;
<developerKey>Your developer key</developerKey>
<build>1</build>
<copyright>(C)All rights reserved.</copyright>
<license>The BSD License</license>
<licenseUrl>http://www.opensource.org/licenses/bsd-license.php</licenseUrl&gt;
</plugin>

</code>

You can get your unique developer key at Oxwall Store >> Developer tools.

3. Create install.php file within your plugin’s folder. Content:

<code php>

<?php
BOL_LanguageService::getInstance()->addPrefix(‘customconsole‘, ‘Custom Console’);

</code>

Where customconsole is your plugin’s key .

4. Create uninstall.php file within your plugin’s folder. Content: you can leave this file empty.

4. Create activate.php file within your plugin’s folder. Content: you can leave this file empty

5. Create deactivate.php file. Content: you can leave this file empty/

6. Create init.php file. Content:

<code php>

<?php
$plugin = OW::getPluginManager()->getPlugin(‘customconsole’);

OW::getRouter()->addRoute(new OW_Route(‘customconsole.index’, ‘custom’, “CUSTOMCONSOLE_CTRL_Custom”, ‘index’));
$eventHandler = new CUSTOMCONSOLE_CLASS_EventHandler();
$eventHandler->genericInit();
$eventHandler->init();

</code>

7. Create /controllers/ directory within your plugin’s folder.

8. Create custom.php file within /contollers/ directory. Name of the file should match contoller’s class name specified in init.php file. Our name in init.php is: CUSTOMCONSOLE_CTRL_Custom , therefore our file will be called custom.php . Content of the file:

<code php>

<?php

class CUSTOMCONSOLE_CTRL_Custom extends OW_ActionController
{
public function index()
{
$this->setPageTitle(“My New Custom Page”);
$this->setPageHeading(“Custom Page”);
}
}

</code>

9. Create /views/ directory within your plugin’s folder. Create /controllers/ directory within /views/

10. Create custom_index.html file within /views/controllers/ directory. Content: any text/html of your choice. Let’s add simple “My cool page will be here” text there for now.

11. Create /classes/ directory within your plugin’s folder name.

12. Create event_handler.php file within /classes/ directory. Content of the file:

<code php>

<?php

class CUSTOMCONSOLE_CLASS_EventHandler
{
const CONSOLE_ITEM_KEY = ‘custompage’;

public function genericInit()
{
}

public function init()
{
$eventManager = OW::getEventManager();

$eventManager->bind(‘console.collect_items’, array($this, ‘collectItems’));

}

public function collectItems( BASE_CLASS_ConsoleItemCollector $event )
{

$language = OW::getLanguage();
$router = OW::getRouter();

$item = new BASE_CMP_ConsoleDropdownMenu($language->text(‘customconsole’, ‘main_console_item’));
$item->setUrl($router->urlForRoute(‘customconsole.index’));
$event->addItem($item, 6);

$item->addItem(‘head’, array(‘label’ => $language->text(‘customconsole’, ‘console_1′), ‘url’ => $router->urlForRoute(‘http://skadate.com&#8217;)));
$item->addItem(‘main’, array(‘label’ => $language->text(‘customconsole’, ‘console_2′), ‘url’ => $router->urlForRoute(‘view_photo_list’)));
$item->addItem(‘main’, array(‘label’ => $language->text(‘customconsole’, ‘console_3′), ‘url’ => $router->urlForRoute(‘desired_route_here’)));

}
}
</code>

13. Save your changes >> compress your plugin’s folder >> uploaded zipped file into /ow_plugins/ directory on your server.

14. Go to your Admin Panel >> Manage Plugins >> Available plugins >> install “Custom Console” plugin.

15. Once plugin is installed you will get new console item at the top of the page:

Screenshot-579

16. To add human readable values instead of text key such as customconsole+main_console_item open following URL: http://www.yoursitename.com/admin/dev-tools/languages  >> Click ” Add New Text”:

– select your custom plugin from drop down.

– enter key you specified in event_handler.php file into the next box. Ex: main_console_item

– enter desired value

Screenshot-580

Result on front end:

Screenshot-581

Do the same for remaining missing text keys used in event_handler.php file. In our case we used:

<code php>

$language->text(‘customconsole’, ‘console_1′)

$language->text(‘customconsole’, ‘console_2′)

$language->text(‘customconsole’, ‘console_3′)

</code>

So you must add console_1, console_2 and console_3 text keys via admin panel.

17. Hover the mouse over your new console’s main item. You will notice that it leads to http://www.sitename.com/customconsole page and show the content you added into /views/controllers/custom_index.html file.

Main item is set to lead to this page in event_handler.php file you created:

BASE_CMP_ConsoleDropdownMenu($language->text(‘customconsole’, ‘main_console_item’));
  $item->setUrl($router->urlForRoute(‘customconsole.index’));
$event->addItem($item, 6);

It is up to you to select and add routes for sub items. At this stage sub items lead nowhere.


About routing


To link your custom console item to already existing pages of Oxwall / SkaDate software you must use routes.

Routes are set in event_handler.php file of your custom plugin.

Ex:    $item->addItem(‘head’, array(‘label’ => $language->text(‘customconsole’, ‘console_1′), ‘url’ => $router->urlForRoute(‘desired_route_here‘)));

You can find out route paths in init.php files of corresponding plugins.

Ex: Link you console item to “Photos” page.

a) open init.php of “Photos” plugin.

b) find needed route. Ex: OW::getRouter()->addRoute(new OW_Route(‘view_photo_list‘, ‘photo/viewlist/:listType/’, ‘PHOTO_CTRL_Photo’, ‘viewList’, array(‘listType’ => array(‘default’ => ‘latest’))));

c) add found route into event_hander.php of your custom plugin.

Ex: $item->addItem(‘head’, array(‘label’ => $language->text(‘customconsole’, ‘console_1′), ‘url’ => $router->urlForRoute(‘view_photo_list‘)));

11 thoughts on “SkaDate / Oxwall : how to add new console item

  1. Hello there I am so thrilled I found your blog, I really found you by error, while I was looking on Askjeeve for something else, Nonetheless I am here now and would just like to say thank you for a tremendous post and a all round interesting blog (I also love the theme/design), I don’t have time to read through it all at the minute but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the great job.

    Like

  2. I’m really enjoying the theme/design of your web site. Do you ever run into any browser compatibility issues? A small number of my blog readers have complained about my blog not working correctly in Explorer but looks great in Chrome. Do you have any advice to help fix this issue?

    Like

  3. Using the virtual private network in Belarus does eliminate the frustrations felt by being blocked from these sites because your access is renewed. She therefore determines to join Van, tagging along despite his protests and takes up the role of his sidekick. So here, let me just show you the steps on how to write a video script in general:.

    Like

  4. / There are some inttneseirg points in this article however I don’t know if I see all of them middle to heart. There is some validity but I will take hold an opinion until I look into it further. Good article , thanks and we want more! Added to FeedBurner as well.

    Like

  5. I see everyone cocking using special ropes and crB#us&n8230;akt if someone your size can cock a 225 recurve i see using those devices as extra time..unless of coarse someone is very weak of handy capped..I also made a great back stop using blanket old jeans and shirts works great..bolts dont get damaged and are very easy to remove..I have a 315 fps..but will be getting another 375fps pedator real soon..lots of fun to shoot

    Like

  6. Hello, i have searched both this forum and also other pages and in my admin section, but i could not find where to setup new user role permission.

    Is this even possible in Oxwall (im actually using skadate, but this may be a feature for Oxwall)?

    The role i am looking for to add, is that paid members should be abel to define search for more than free users.
    Like: Hair color/Body type/eye color etc. etc.

    Thank you all 🙂

    Like

  7. Hello, i have searched both this forum and also other pages and in my admin section, but i could not find where to setup new user role permission.

    Is this even possible in Oxwall (im actually using skadate, but this may be a feature for Oxwall)?

    The role i am looking for to add, is that paid members should be abel to define search for more than free users.
    Like: Hair color/Body type/eye color etc. etc.

    Thank you all 🙂

    Like

  8. Sorry admin, i post 3 comments in this post.

    Hello, i have searched both this forum and also other pages and in my admin section, but i could not find where to setup new user role permission.

    Is this even possible in Oxwall (im actually using skadate, but this may be a feature for Oxwall)?

    The role i am looking for to add, is that paid members should be abel to define search for more than free users.
    Like: Hair color/Body type/eye color etc. etc.

    Like

  9. Heisann…og god ny uke til deg ogsÃ¥ :o)SÃ¥ synd at storebror har fÃ¥tt halsbetennelse…hÃ¥per han blir fort frisk nÃ¥ nÃ¥r han har fÃ¥tt medisiner…krysser fingrene for at du og lille vesla slipper unna.Og du…digger ukesmenyen din pÃ¥ siden her…sÃ¥ kjekt med ideer,takk :o)Klem Hege

    Like

Leave a comment