Friday, May 28, 2010

Module Positons in Joomla in 1.0 and 1.5

How to create New positions in joomla:

Joomla 1.0.X version:

In joomla 1.0.X versions we will create the new module positions like this

go to site->template manager->module position

in that create new module position and save it by clicking the save button on the top right of the screen
Now your new module position is published.

then go to the content->section manager. create a new section by clicking the new button on the top right of the screen. and save it.

then go to the content->category manager. create a new category by clicking the new button on the top right of the screen. and save it.

For example i have created a section “test” and created a category “test”, then in order to create a content

go to content->content by section->test->test items

in that click the new button on the top right create the name of your content and section and category.

Then in the content area write these lines to publish your module in the desired page.

{mosloadposition MODULE}

this “MODULE “ is the position name you have created in moduleposition.

Go to module manager and select your module and give the position as “MODULE”

So that your module that was created by you or the installed module will be displayed in the desired page and location.

Joomla 1.5.X version:

In joomla 1.5.X versions we will create new module position like this

Install the module and copy the module by selecting the module and clicking the copy button on the top right corner of the screen.

then the copy module name will be "copy of module"

click on the "copy of module" change the module name and there is a column called position dropdown box will be there.

Generally we need to select the position from the dropdown box. But in this case it is an editable box even though it is a dropdown.

Give the name of the new position that should not be there in the dropdown. and enable it..

Now the new position name is let us say "MODULE"

i want to publish this module in my article page..

Go to the content->section manager. create a new section by clicking the new button on the top right of the screen. and save it.

then go to the content->category manager. create a new category by clicking the new button on the top right of the screen. and save it.

For eample i have created a section test and created a category test.then in order to go to content.

Go to Content->article manager. create a new article by clicking the new button on the top right corner of the screen.

give the name of the article and section and category.

write these lines where ever you want the module to be published on the page

{loadposition MODULE} MODULE is the name of the new module position.


Troubleshooting for joomla 1.5.X:


if the module is not shown on the desired page. check the plugin like this

Go to extensions->plugin manager. in that check whether Content - Load Module is published or not...,

If it is not published publish by clicking the 'x' mark in the enable column.

Once it is published then click on Content - Load Module. change the plug-in parameters.

In plug-in parameters there will be style dropdown..., click on the dropdown and select "No Wrapping(raw output)".

Blog by Satish M

Monday, May 24, 2010

Generate PDF using html2pdf Zip.

Hi Developer,
I got a requirement to generate pdf using php... Luckily with the help of my Innocent Boy i finished the task & posting blog to all.

Generating PDF:

There are many pdf libraries which can be used to generate pdf files.
Here I have used html2fpdf which internally uses fpdf library to convert html to pdf. We will add header and footer to the generated pdf also.

A sample project can be downloaded here http://www.macronimous.com/resources/html2pdf_sample.zip

First Let us generate basic pdf file.

Please find the index.php file in the extracted zip.

require('html2fpdf.php');
$pdf=new HTML2FPDF();
$pdf->AddPage();

$html = “Your HTML HERE”;
$output=($html);
$pdf->WriteHTML($output);
$pdf->Output("sample.pdf");
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=download.pdf");
readFile("sample.pdf");
?>

Above sample code will generate a pdf with text “Your HTML HERE” and prompt user to download the generated pdf.

To add header and footer you can use already available functions.They are called automatically. They already exist in the FPDF class but do nothing, therefore we have to extend the class and override them.


require('html2fpdf.php');
class PDF extends HTML2FPDF
{
function Header()
{
$this->Image('header.gif',10,8);
}

function Footer()
{
$this->Image('ourpeople.jpg',10,250,33);
}

}

$pdf=new PDF();
$pdf->AddPage();
$html = “Your HTML HERE”;
$output=($html);
$pdf->WriteHTML($output);
$pdf->Output("sample.pdf");
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=download.pdf");
readFile("sample.pdf");
?>

Now header and footer will be added to the generated pdf.

There are lot more functions in FPDF and we cannot cover all those.
To learn FPDF, please browse http://www.fpdf.org.


NOTE : GIF image solution
I think you face problem while using gif image in the pdf generation.so to avoid use link
http://code.google.com/p/html2pdf/issues/detail?id=2#c5 and download the gif.php and replace gif.php in html2pdf directory.

Gud Luck Developers.

Sunday, May 16, 2010

Working on CustomPage Module in Drupal 6.x

Custom Page:

Custom Page is an advanced theming tool, allowing developers to easily create pages with custom templates and maintain full control over the output.

This module can be downloaded from http://drupal.org/project/custompage.

Once, downloading is done extract and place in your modules folder.

To add a custom page go to Administration > Site building > Custom pages
List of available templates will be listed here. As we did not add any yet, none will be seen.


Click on 'Add a custom page or block', below screen will be seen.


Note: If above screen is not seen, make sure 'Custom Page Admin UI' module is enabled which is bundled with this module.

Type in the Title, URL path and Key attributes for a custom page. "Key" is the name of a template file which you want to assign. For example, if 'test' is given as key and 'test' is given in URL Path, Now when link 'test' is being accessed from site, it looks for test.tpl.php file for the template.
You can disable a page/block during development by unchecking the check box. Only users with 'administer custompage' permission can access the page when it is disabled.

Once you are done with filing in the fields, click on 'Add Component' button. Now page is created succesfully.

Next, we need to create the template file which was given while creating page. In our example key is 'test' so create 'test.tpl.php' in your current themes folder. Components now need to be inserted into the template file.
A node can be inserted into the page using
print custompage_node_tile( $key, $type = '', $teaser_only = FALSE );
where $key can be a node's node id (nid), in which case $type parameter is ignored, or it can be node's title, in which case the node_type needs to be indicated in the second $type parameter. You can insert just a teaser part of the node by passing $teaser_only = TRUE

Similarly views, webforms, Regions, menus can be inserted to the template and theming can be done to make it display as per your wish.

I have added a node with node id '3' by giving
print custompage_node_tile(3, $type = '', $teaser_only = FALSE ); A page with node id 3 is already available in my site.

Clear cache and access the URL 'test'. You can see the content part replaced with the content in the page with node id '3'.



In this way custom pages can be created with already available nodes, views, menus etc with custom theme.

For furthur information http://drupal.org/node/286219 can be accessed.

We help my innocent i'm able to post the article on custom page module in drupal.