Question

I have a main index.php. There is a href link on this PHP, from which I am calling another PHP. There are some jdoc statements in the second PHP. These don't get executed. If I use 'include' in the index.php, then it works properly. It also works if I use href pointing to a location in the same index.php.

index.php code:

<a href="/joomla16/templates/zmtemplate/second.php">Trial</a> 

second.php

<jdoc:include type="modules" name="Header3"             style="none" /> 

<jdoc:include type="modules" name="Header14"            style="none" />                     

No correct solution

OTHER TIPS

First of all you are trying to access a page that is not part of Joomla framework.

In Joomla you can't just explicitly use new pages like second.php or something else.

Its based on MVC, you have to write component or module for your task based on your requirement.

Component gives a wide option for your requirement like form submission ,different pages (layouts) etc. Module is the smallest unit it just display the content (from DB or static) any where in the view page (you can include multiple module in a page.)

Another Dirty option is to achieve your requirement very quickly is as below.

Instead of loading second.php inside template use it in the root then include Joomla frame works to that page, USE ht-access to create some SEF URL for this page, you can use below script to include Joomla frame work.

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root,means path to Joomla installation
define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();

hope it make sense..

Or you have to describe more in details what are you trying to achieve.

Make sure in the second.php file you have imported the Joomla! framework functions in order for you to use functions such as <jdoc:include type="modules" style="xhtml" /> and the rest. Try something like this in the very beginning of your second.php file;

<?php
 defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
JHtml::_('behavior.framework', true);
?>

After doing that, now you can call your jdoc include statement and see if it works. Hope this helps.

Joomla needs an entry point file which sets up the Joomla application and fires off all the steps involved in generating your page. This is not the index.php file in your template directory. It is the index.php file in your base Joomla directory.

In your template directory, the index.php file is just the default template (not the entry point to the application). You can load a different template by passing tmpl=<filename> in the query string of your url (there are also some other good ways of accomplishing this). But the templating system is pretty versatile, you may not actually need a different template file at all.

You need to learn HTML, CSS, Then PHP & MYSQL. Once you understand all that you can learn Joomla.

PHP & MYSQL are somewhat optional but I strongly recommend understanding them to fully use Joomla.

Your <jdoc> statements need to be used within a Joomla template within a Joomla installation. You can't just put a <jdoc> statement in any random index.php file and hope they work. You need the joomla template engine to render those tags correctly.

Your right if you use include() in any plain .php file like this :

<?php include('filename.php'); ?>

That will work without Joomla. So you need to start with the basics first.

Check out Lynda.com for training videos on all theses subjects or even lookup theses subjects on youtube.com

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top