Page 1 of 1
How can i load template ?
Posted: Wed Sep 19, 2007 8:26 pm
by javid
I write a simple funny code
Code: Select all
<?php
DEFINE('_VALID_MOS','javid');
require( 'globals.php' );
require_once( 'configuration.php' );
require_once( 'includes/joomla.php' );
$query = ("SELECT * FROM #__users ");
$database->setQuery( $query );
$rows = $database->loadObjectList();
$x = count( $rows );
echo "<table cellspacing="4" cellpadding="4" bordercolor="#000000">";
echo "<tr>";
echo "<td colspan="15">There is ".$x." User </td>";
echo "</tr>";
$k = 0;
for ($i=0, $n=count( $rows ); $i < $n; $i++) {
$row = &$rows[$i];
echo "<tr>";
echo "<td><b>User ID</b> : $row->id</td>";
echo "<td><b>Name</b> : $row->name</td>";
echo "<td><b>User Name</b> : $row->username</td>";
echo "<td><b>E-mail</b>: $row->email</td>";
echo "<td><b>Register Date</b>: $row->registerDate</td>";
echo "<td><b>Last Login</b>: $row->lastvisitDate</td>";
echo "</tr>";
}
echo "</table>";
?>
But i have a question : how can i use my joomla template & load the result in Mainbody ? I don't want to write a component ....
Is It possible ? :
Re: How can i load template ?
Posted: Thu Sep 20, 2007 7:07 am
by javid
impossible ?
?
Re: How can i load template ?
Posted: Thu Sep 20, 2007 8:24 am
by Darius
Hi, no that's possible. Just put this code snippet to module (
http://help.joomla.org/content/view/20/60/) and then you would be able to load this module where ever you want
Re: How can i load template ?
Posted: Thu Sep 20, 2007 8:44 am
by javid
TNX Darius...
I don't want to make a module !
i want to have my own file !
IE -> MYDOMAIN.COM/javid.php
now i have my file & i can see the content ...
but i want to load my result in my site template
Re: How can i load template ?
Posted: Thu Sep 20, 2007 9:20 am
by Darius
Hmm, maybe you can use php include() statement in your template index.php file:
Code: Select all
<?php include 'MYDOMAIN.COM/javid.php'; ?>
or maybe one of these extensions will help to solve your problem:
http://extensions.joomla.org/index.php? ... &Itemid=35
Re: How can i load template ?
Posted: Thu Sep 20, 2007 9:33 am
by javid
0ow !
have u any joomla site ?
make new PHP file ie ( darius.php ) & put my code in your file then upload file to your joomla root & see what happen
i dont want to include my file in template i want to include template in my file !!!!!
no module no component !
0ok ?
Re: How can i load template ?
Posted: Thu Sep 20, 2007 9:50 am
by Darius
have u any joomla site ?
make new PHP file ie ( darius.php ) & put my code in your file then upload file to your joomla root & see what happen
so i saw couple of notices (Joomla 1.0.13) due to wrong code, after adding some corrections:
Code: Select all
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$query = ("SELECT * FROM #__users ");
$database->setQuery( $query );
$rows = $database->loadObjectList();
$x = count( $rows );
echo "<table cellspacing="4" cellpadding="4" bordercolor="#000000">";
echo "<tr>";
echo "<td colspan="15">There is ".$x." User </td>";
echo "</tr>";
$k = 0;
for ($i=0, $n=count( $rows ); $i < $n; $i++) {
$row = &$rows[$i];
echo "<tr>";
echo "<td><b>User ID</b> : $row->id</td>";
echo "<td><b>Name</b> : $row->name</td>";
echo "<td><b>User Name</b> : $row->username</td>";
echo "<td><b>E-mail</b>: $row->email</td>";
echo "<td><b>Register Date</b>: $row->registerDate</td>";
echo "<td><b>Last Login</b>: $row->lastvisitDate</td>";
echo "</tr>";
}
echo "</table>";
?>
added this line:
after in my template index.php file and everything works fine.
Re: How can i load template ?
Posted: Thu Sep 20, 2007 10:02 am
by javid
If you add the include code you see results in all of your pages !
i want to see the result here ->
http://mydomain.com/myfile.php not in index.php
(
(
(
(
(
(
Re: How can i load template ?
Posted: Thu Sep 20, 2007 2:02 pm
by ianmac
Any particular reason why?
I mean... sure it's possible, but it seems to me that you're reinventing the wheel...
This isn't a simple thing and if you really want to do it, you can, but good luck...
Ian
Re: How can i load template ?
Posted: Thu Sep 20, 2007 2:37 pm
by javid
Hi Ian
Yeah I have a particular reason
Can u help me ?
Re: How can i load template ?
Posted: Thu Sep 20, 2007 2:44 pm
by ianmac
Sorry... that gets messy and I don't have the time to wade through it at this point.
Ian
Re: How can i load template ?
Posted: Fri Sep 21, 2007 8:11 am
by jcisio
I think the simplest way to do it is to use the template trick.
Suppose that you use SEF or some rewrites in .htaccess so that myfile.php executes index.php. Then edit your templates/xxxxxx/index.php: change mosMainBody() by this:
Code: Select all
if ($_SERVER['REQUEST_URI'] == '/myfile.php') include('myfile.php')
else mosMainBody();
Hope it helps. Feel free to change REQUEST_URI with anything like PHP_SELF, SCRIPT_URL...