How can i load template ?

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
javid
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sun Apr 02, 2006 1:55 pm
Location: Kerman , Iran
Contact:

How can i load template ?

Post by javid » Wed Sep 19, 2007 8:26 pm

I write a simple funny code  ;D

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 ? : ???
Javid Momeni
Head of Technical Department
Sika Technology Development

Jaavid.com

User avatar
javid
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sun Apr 02, 2006 1:55 pm
Location: Kerman , Iran
Contact:

Re: How can i load template ?

Post by javid » Thu Sep 20, 2007 7:07 am

impossible ?
????
Javid Momeni
Head of Technical Department
Sika Technology Development

Jaavid.com

User avatar
Darius
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Dec 11, 2005 2:41 pm
Contact:

Re: How can i load template ?

Post by Darius » Thu Sep 20, 2007 8:24 am

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 ;)

User avatar
javid
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sun Apr 02, 2006 1:55 pm
Location: Kerman , Iran
Contact:

Re: How can i load template ?

Post by javid » Thu Sep 20, 2007 8:44 am

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 :(
Javid Momeni
Head of Technical Department
Sika Technology Development

Jaavid.com

User avatar
Darius
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Dec 11, 2005 2:41 pm
Contact:

Re: How can i load template ?

Post by Darius » Thu Sep 20, 2007 9:20 am

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

User avatar
javid
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sun Apr 02, 2006 1:55 pm
Location: Kerman , Iran
Contact:

Re: How can i load template ?

Post by javid » Thu Sep 20, 2007 9:33 am

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 :D
i dont want to include my file in template i want to include template in my file !!!!!
no module no component ! :D 0ok ?
Javid Momeni
Head of Technical Department
Sika Technology Development

Jaavid.com

User avatar
Darius
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Dec 11, 2005 2:41 pm
Contact:

Re: How can i load template ?

Post by Darius » Thu Sep 20, 2007 9:50 am

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:

Code: Select all

<?php include 'example.php'; ?>

after in my template index.php file and everything works fine.

User avatar
javid
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sun Apr 02, 2006 1:55 pm
Location: Kerman , Iran
Contact:

Re: How can i load template ?

Post by javid » Thu Sep 20, 2007 10:02 am

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 :(( :(( :(( :(( :(( :((
Javid Momeni
Head of Technical Department
Sika Technology Development

Jaavid.com

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: How can i load template ?

Post by ianmac » Thu Sep 20, 2007 2:02 pm

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
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

User avatar
javid
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Sun Apr 02, 2006 1:55 pm
Location: Kerman , Iran
Contact:

Re: How can i load template ?

Post by javid » Thu Sep 20, 2007 2:37 pm

Hi Ian
Yeah I have a particular reason :D
Can u help me ?
Javid Momeni
Head of Technical Department
Sika Technology Development

Jaavid.com

User avatar
ianmac
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 237
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: How can i load template ?

Post by ianmac » Thu Sep 20, 2007 2:44 pm

Sorry...  that gets messy and I don't have the time to wade through it at this point.

Ian
Help test my Component XML Generator Tool!
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,1997/Itemid,35/
All feedback appreciated!

jcisio
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Apr 16, 2007 2:33 pm
Contact:

Re: How can i load template ?

Post by jcisio » Fri Sep 21, 2007 8:11 am

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...
Last edited by jcisio on Mon Sep 24, 2007 1:39 pm, edited 1 time in total.
http://thongtincongnghe.com/ - Thông tin công nghệ


Post Reply