phprockers-logo

Display the custom file in cms block to frontend/backend in Magento

0 comments
Below coding can be used to show CMS block in Frontend.

Ref. Path :  app/design/frontend/base/default/template/callouts/left_col.phtml or right_col.phtml.

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_id')->toHtml(); ?>

Setting in Backend:

First Go to CMS and create a static page. Here we take "identifier" id from static block and put this id to above coding inside setBlock_id. And inside content we have put following line for calling our own block coding file,

{{block type="core/template" name="leftnav_menu" template="menu/menu.phtml"}}

Finally we have saved the file and this file is running in frontend inside the block.


Database connection in Joomla 2.5

0 comments
We have easy to connect database in joomla 2.5. Using below function
we have to connect database wherever you want in joomla folder.
 
$db =& JFactory::getDBO();

What is MVC in Joomla?

1 comments
MVC - Model-View-Component

“MVC consists of three kinds of objects. The Model is the application object, the View isits screen presentation, and the Controller defines the way that the user interface reacts tothe user input.

Create a custom page template in wordpress

0 comments
we have a sidebar on all of pages in wordpress website, but we want to have a page that doesn’t have a sidebar. Here is how we create a custom page template without a sidebar in wordpress:

1)   Create a new file in wordpress theme folder and name it withoutSidebar.php.

2)   Open page.php and copy all of the code and paste it into the newly created withoutSidebar.php.

3)   Make any changes that you would like to withoutSidebar.php. In this example we are going to remove the sidebar, so find the code that calls the sidebar (<?php include(‘sidebar.php’); ?>) and remove it.

4)   You may also want to find the div that contains the main container and add a width style to make it cover the whole page.

5)   Finally, and most importantly, add the following line of code to the top of the page. This code is used to tell WordPress that this is a custom template. Without this code, WordPress would not be able to find the template:


<?php
    /*
   Template Name: without Sidebar
   */
 ?>

6)     Save this file and upload it to your server.

Difference between Primary Key and Unique key in mysql?

0 comments
Difference between Primary Key and Unique key in mysql/sql/oracle?

SNO Primary Key Unique Key
1 Primary Key does not allow NULLs values in a table Unique Key allows Nulls value in a table
2 Only one primary key will be there in a table More than one unique key will be there in a table
3 Clustered index is created in primary key in a table Non-Clustered index is created in unique key in a table
4 Primary key allows each row in a table to be uniquely identified and ensures that no duplicate rows exist as well as does not allow the duplicates values in the rows of a table. Unique key constraint is used to prevent the duplication of key values within the rows of a table and allow null values

By default Primary Key creates a Clustered Index on the column as same as Unique Key creates a Nonclustered Index. Another major difference is Primary Key doesn’t allow NULLs, but Unique Key allows NULLs. We can create only one primary key in a table, but a table can have the multiple unique key.

Update query in mysql

0 comments
The syntax for Update the row into tables,

UPDATE
    table_name SET (colname1, colname2, colname3 ...) VALUES (value1,value2,value3,...) WHERE colname = row_values;   

<?php

$con = mysql_connect('localhost', 'root','');
mysql_select_db('dbname', $con) or die(mysql_error());

$query = "UPDATE table_name SET rank="2" WHERE sno = 2";   
$ok = mysql_query($query);

if($ok)
echo "Updated row successfully";
else
echo "Failed to update the row in the table";

?>


sno name marks rank post_of_date
2 krishnan 397 2 09-04-2001
3 PHP Developer 521 36 27-03-2012

Delete query in mysql with php

0 comments
The syntax for Delete the row into tables,

DELETE FROM
    table_name WHERE colname = row_values;    

<?php

$con = mysql_connect('localhost', 'root','');
mysql_select_db('dbname', $con) or die(mysql_error());

$query = "DELETE FROM table_name WHERE sno = 1";    
$ok = mysql_query($query);

if($ok)
echo "Deleted row successfully";
else
echo "Failed to delete the row in the table";

?>



sno name marks rank post_of_date
2 krishnan 397 3 09-04-2001
3 PHP Developer 521 36 27-03-2012