Sunday, April 29, 2012

Create your own CMS-Part 12

So far we have coded all the necessary class files.
Here we will create our first module 'home'.Before creating our first module,let us add two more functions in 'functions.php' in 'main' folder.
/***************************
Builds menu (left)
$menu argument must be an array
****************************/
function build_menu($menu)
{
foreach ($menu as $name=>$link)
{
 show_menu($name,BASE.$link);
}
}
build_menu function is used to build a menu for navigation.It accepts an array $menu as parameter with key indicating the name of the menu and value indicating the link.
Now add another function to show the menu.
/***************************
Shows the menu
****************************/
function show_menu($name,$link)
{
echo '<a href="'.$link.'" class="left_menu">'.$name.'</a>';
}
Creating the homepage
The homepage of our site will contain a register form and login form.
Homepage is theme based .
Open the 'default' themes folder and create 'homepage.php'.
Edit this file with your contents.
Homepage should be simple and attractive.
Download the theme with new homepage from the link below as an example.

Download default theme

Creating the first module

Home module doesn't require the necessary files to be valid.
It is valid by default.The home module, we are going to create will have only two files.
  • view.php              -      content in app_block area.
  • left_menu.php      -      menu for navigation.
Open modules folder.
Create a folder and name it as 'home'.
Create two files as mentioned above.

view.php

You can write whatever here to meet your requirements.

You might love this quote!!!

<div class="content_wrapper">
<h3>
"We've demonstrated a strong track record of being very disciplined with the use of our cash. We don't let it burn a hole in our pocket, we don't allow it to motivate us to do stupid acquisitions. And so I think that we'd like to continue to keep our powder dry, because we do feel that there are one or more strategic opportunities in the future." 
--
</h3>
</div>
<h2>
<a href="http://www.blogger.com/blogger.g?blogID=5175690629178451362">Steve Jobs </a></h2>

left_menu.php

<div id="left_menu">
$menu = array('Photos'=>'/#','Videos'=>'/#');
build_menu($menu);
if(is_admin())
{
echo '<a class="left_menu" href="http://www.blogger.com/'.BASE.'/admin/">Admin</a>';
}

?>
Navigation is created using the two functions we created in the begining of this post.



8 comments:

  1. Can I ask a question?
    We build a CMS to manage our website dynamically from our database, right?

    Why to use this cms, if the text in homepage.php is not in database and i can't manage it in that way?

    ReplyDelete
  2. I agree with you Haroula.
    "We build a CMS to manage our website dynamically from our database".But the homepage.php created here is just for an example.Also,we have not yet created well defined module.The homepage.php will look more dynamic after we create blog module with recent blog posts,comments etc

    ReplyDelete
  3. Ok then, i 'll wait for your next tutorials!! Thank you!!! :)

    ReplyDelete
  4. Hello, when do the next part come

    ReplyDelete
  5. this series will be resumed after a short period.

    ReplyDelete
  6. Hi, thanks for your blog, if you want to learn about programming languages like java, php, android app, embedded system etc. I think this training institute is the best one.
    best python training in coimbatore
    Android training in coimbatore
    Networking training in coimbatore

    ReplyDelete
  7. These bonuses can consist of a mixture of free spins and free cash. They are frequently supplied as much-appreciated bonus rewards or as a welcome bonus. It 카지노 사이트 type of|is type of} frequent that gamers win free spins while enjoying in} on slot machines is in a position to} cause the machine to continue to spin without additional costs. Connecticut might not have as many on-line casinos as other states in the USA, however what it does have is spectacular.

    ReplyDelete