Hi all, today i am going to tell you how to create a pyrocms widget in some easy steps. Widgets are a small program to show some text or some login form etc on your website. The widget we are going to develop in this tutorial, also outputs some simple text on sidebar. So here are the steps,
1. First you have to download and install pyrocms package from pyrocms website. You can do so by clicking here.
2. Now extract the package in your www folder of your wamp server and follow installation steps shown in installation wizard.
3. Next you have to create a folder in widgets folder. Let say we create a folder my_first_widget in widgets folder. In my case this is located here C:\wamp\www\pyrocms\addons\shared_addons\widgets\
4. Now you have to create a file called my_first_widget.php in my_first_widget folder. Be sure to use the same name as for your widget folder name. This is very must for your widget to work.
5. Next put following code in my_first_widget.php file and save it,
6. Now you have to create a folder in my_first_widget folder and name it as "views".
7. Next create a file display.php in views folder and put following code in that file.
8. Now login to pyrocms admin panel and go to widgets section. Drag and drop my_first_widget widget in sidebar tray. Then refresh your front end page and see "This is my first widget" text displayed in sidebar.
Thats it, please feel free to post your comments and share this tutorial if you find this useful for you.
Thanks
1. First you have to download and install pyrocms package from pyrocms website. You can do so by clicking here.
2. Now extract the package in your www folder of your wamp server and follow installation steps shown in installation wizard.
3. Next you have to create a folder in widgets folder. Let say we create a folder my_first_widget in widgets folder. In my case this is located here C:\wamp\www\pyrocms\addons\shared_addons\widgets\
4. Now you have to create a file called my_first_widget.php in my_first_widget folder. Be sure to use the same name as for your widget folder name. This is very must for your widget to work.
5. Next put following code in my_first_widget.php file and save it,
<?php
class Widget_my_first_widget extends Widgets
{
//The following information will appear when you will install the widget
public $title = 'This is my first widget';
public $description = 'Puts default text.';
public $author = 'Asad Mehmood';
public $website = 'http://our-knowledge-base.blogspot.com/';
public $version = '1.0';
}
?>
6. Now you have to create a folder in my_first_widget folder and name it as "views".
7. Next create a file display.php in views folder and put following code in that file.
<?php echo "This is my first widget"; ?>
8. Now login to pyrocms admin panel and go to widgets section. Drag and drop my_first_widget widget in sidebar tray. Then refresh your front end page and see "This is my first widget" text displayed in sidebar.
Thats it, please feel free to post your comments and share this tutorial if you find this useful for you.
Thanks
what!!! only that?
ReplyDeleteThis widget was so simple.
yet i don't know what it was... :) @newbiealert
yeah dear, creating pyrocms widget is very simple task to do. Purpose of my post is to show my blog readers, the basics of this.
Deletethanks for reading and commenting :)
i draged and droped already and click save after input title for this but this dont display at frondtend. Infact have no sidebar at frontend
ReplyDeletedear, did you follow all the steps mentioned in this post. I double checked this and this is working fine with me.
Deletei'm missing something here because i don't see a wizard in the package linked in step 1.
ReplyDeleteDear loki, i have tested this on my laptop and its working fine with me. May be you have downloaded wrong package or something like this. can you test it again?
DeleteThanks
Hi Asad....your pluging...what it does ??
ReplyDeleteThans
this plugin is showing how to create plugins in pyrocms. It displays a simple text at front end and by this way you will have better understanding of how to develop widgets in pyrocms. It can be customized to make it as you like.
DeleteIts working fine for me..thank you very much ir for this tutorial...glad if you can provide some more useful topics on pyrocms..
ReplyDeleteThanks. and sure why not
Deletei want to put a module in widget ..how can i do this?
ReplyDeleteThanks. was a good first basic step in learning PyroCMS.
ReplyDeleteHow my_first_widget.php will associate with display.php? You haven't load view nevertheless it will work?
ReplyDeleteHi asad,
ReplyDeletegood post :)
have an question.
can i display the sample widgets only on certain pages in sidebar pyrocms.
because my custom widgets are vary in different pages.
Ex:
In Video page , side bar widgets are "latest video comments" , "user navigation" , "latest upload videos"
In blog page ,side bar widgets are "latest blog comments" , "user navigation" , "latest upload blogs"
In music page ,side bar widgets are "latest music comments" , "user navigation" , "latest upload musics"
Is it possible? Give me some examples .
Thanx.
vasa
yeah there are different methods or techniques to achieve this. Best solution is to have separate layouts for each page and then display different widgets in different layouts
Deletethnx for your quick comments :)
DeleteIf any possibilities to modify the different widgets in same layouts?
yeah you can do like this. set a variable in module or controller and then check that variable value in layout and display appropriate widgets
Deletegood and thnx keep rockz in pyrocms :)
Deletethanks
DeleteHi Asad Mehmood,
ReplyDeleteCan you let mt know about, How to manage multi-language on front site with Pyrocms
Second Question is -:
How to connect module with another db, I mean i want to use external database with pyrocms site.
Thanks.