7

I have a question, I have an already constructed site, we use Joomla for the CMS, and a theme from RocketTheme called "Diametric". We are looking to construct a page and it's styling is going to fall pretty far outside the confines of the template. Is it possible to develop a coded HTML/CSS page, let's say using the Bootstrap Framework, and store it within the file path for our current domain? As I understand it, it would be a page outside the CMS, but still within domain. Am I overlooking anything in doing this? Should I expect any problem behaviour from Joomla?

2 Answers 2

8

In the index.php file of your folder, such as \joomlaroot\yourfolder\index.php, load just the framework of your Joomla site, use the following code:

Once that is done, you have full access to "everything Joomla".

<?php
if (!defined('_JEXEC')) {
    define( '_JEXEC', 1 );
    define('JPATH_BASE', dirname(dirname(__FILE__)));
    require_once ( JPATH_BASE .'../includes/defines.php' );
    require_once ( JPATH_BASE .'../includes/framework.php' );
    defined('DS') or define('DS', DIRECTORY_SEPARATOR);
}
?>
<!DOCTYPE html>
<html>
    <head>
        <title>My Outside-of-Joomla Page</title>
    </head>
    <body>
        <?php
        $user = jFactory::getUser();
        if($user->id){
            echo '<h1>Hello '.$user->name.'</h1>';
        }else{
            echo 'You are not logged into Joomla';
        }
        ?>
    </body>
</html>

It's also interesting to note that within the \cli folder is a sample of loading just the framework for just that - "cli" use - very handy for running scheduled tasks and the like for your Joomla site..

5
  • I'm having a bit of a difficult time understanding what this does exactly. Could you break it down a bit for me? Dec 11, 2014 at 21:01
  • I've edited the answer to include a fully functional index.php file. In short, with the framework loaded, you full access to everything as though you were using the Joomla CMS, but none of it is required. You can put in whatever your design and code is all about, all the while accessing the database, and most other functions from Joomla if you need them.
    – GDP
    Dec 11, 2014 at 21:10
  • 1
    Wow, this is really awesome, I had no idea that this could be done this way. Is this from the documentation? I wasn't able to find this information when searching. Dec 11, 2014 at 21:16
  • It is, but I get lost in the docs with all the versions, etc.
    – GDP
    Dec 11, 2014 at 21:18
  • To those following this script, there is an issue with the directory path. remove the two dots ".." before the includes path, or you can place the "define('DS', DIRECTORY_SEPARATOR);" after the JPATH_BASE is defined and then used these code require_once( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once( JPATH_BASE .DS.'includes'.DS.'framework.php' ); Oct 11, 2015 at 8:20
3

You can. If you use, say, Akeeba Admin Tools Pro you are going to have to put in some exceptions, but generally Joomla does not care what you have in folders and/or files it doesn't use.

But you probably should not. You can assign the active template per menu item. So simply assign your "sub-site" a template that looks like you want it to. I doubt finding or even making a simple template that fits your needs would be that hard.

Also, RocketTheme templates allow you to relatively easily create "template overrides" with modified settings and assign those to menu items. Basically, you use either "save as copy" from the template or "duplicate" from the template manager.

3
  • @ville-nieme I'm interested in the template overrides, but for simply styling a particular section of a give page. If I wanted to say, surround a table, let's say in a overall <div class="special-table> and then assign an override for the following styling: zurb.com/playground/responsive-tables Where would I go about doing this? Is it a problem that I want to include some custom JS as well. I'm not completely new to coding, but I have never designed a Joomla or Wordpress template. Dec 11, 2014 at 20:58
  • @ParanoidPenguin No, adding css or js to Joomla pages is not really difficult. As a matter of fact there are so many ways of doing it, I have problems giving specific advice. You don't really need to do it with templates either. If we assume a single page, that is, you don't need to do this anywhere else, you can simply create a custom HTML module assigned to the page and then in non-wysiwyg mode paste the js and css into it. Or you can use any of the many extensions that can do it with more style. Or add it to the template. Or... you get the idea. You can add class attributes in the editor. Dec 11, 2014 at 21:23
  • ...I know this might be pretty basic, so my enthusiasm may be a bit much, but you kind of just made my night. I'm going to try this tonight and hopefully I end up with some classy looking tables. Thanks so much for your help. Dec 11, 2014 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.