Solved

Trouble creating custom joomla template - template not appearing in admin

Posted on 2011-02-26
22
836 Views
Last Modified: 2012-05-11
Hi, I'm creating my first joomla template and I've followed the instructions of this tutorial:

http://docs.joomla.org/Tutorial:Creating_a_basic_Joomla!_template

However, despite my creating the folder "custom" in /templates and putting these files in:

/templates/custom/templateDetails.xml
/templates/custom/index.php

...  It doesn't appear when I go to "templates" when logged in as admin.  The other templates (preinstalled) do show up, but not the one I just created...
0
Comment
Question by:EMB01
  • 11
  • 9
  • 2
22 Comments
 
LVL 13

Accepted Solution

by:
joomla_php earned 500 total points
ID: 34988177
Do the first steps, creating index.php and templateDetails.xml.

In templateDetails.xml, in this section:

 <files>
                <filename>index.php</filename>
                <filename>component.php</filename>
                <filename>templateDetails.xml</filename>
                <filename>template_thumbnail.png</filename>
                <filename>images/background.png</filename>
                <filename>css/template.css</filename>
        </files>
       

Remove lines so it looks like this instead:

 <files>
                <filename>index.php</filename>
                <filename>templateDetails.xml</filename>
</files>
       

Assuming you're on Windows (not mac or linux) ...

Go get 7-zip, install it.

Start, run, cmd

cd to the directory containing "custom"


C:\yourdirectory>"c:\program files\7-zip\7z" a custom.zip custom

That line says:

Use 7z.exe to create custom.zip from the contents of the custom directory.

You've now created custom.zip.

Now go to your joomla install area, install custom.zip.

Go to your templates area, set mynewtemplate as your default template.

0
 
LVL 14

Author Comment

by:EMB01
ID: 34988244
Okay, thanks.  So, how do I go about updating the template?  Do I have to zip and upload it this way every time?
0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34988299
technically you can change the index.php, add a link to css, add a css -- you don't have to zip it each time.
0
 
LVL 14

Author Comment

by:EMB01
ID: 34988309
What about when changing the XML?  Does that have to be zipped each time?  I would love to be able to update the template via FTP like when doing a normal website.
0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34988366
the xml is only for installation. once the template is the default you can mess with its component files without re-installing.
0
 
LVL 14

Author Comment

by:EMB01
ID: 34988423
I just tried to change the index.php page and uploaded it via FTP but no changes were evident when I refreshed the page in the web browser.  What am I doing wrong to update the index.php page?
0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34988585
I didn't say it would work - I only said that you'd be able to see it in the administrator.

You still have to do the rest of the work.

Don't forget we removed items from xml that need to be put back to continue the tutorial.
0
 
LVL 14

Author Comment

by:EMB01
ID: 34988605
So, FTP updates won't work?  To clarify, I'm asking you how can I make changes to the code of the template (not the article content).  Do I need to re-package and uploaded through the UI?
0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34988668
I might have misunderstood you -- given the work we've done so far, you will get a blank page when yhou load the template.

I also mis-spoke. You do want to get to the point where you have added back in the lines we deleted in the xml, make an installation out of that, and re-install.

You need those other files.

I was just getting you to where you could see it in the admin.

0
 
LVL 12

Expert Comment

by:panagiotiss
ID: 34988684
in templateDetails.xml you have to put

<name>the name of your template</name>

for your template
<name>custom</name>


0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34988693
that's in the original tutorial, i didn't change it. It works the way it is, mynewtemplate, but it can be changed to custom as well.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 14

Author Comment

by:EMB01
ID: 34988770
Okay, thanks for your help so far.  How do I get my externals such as images, javascript and css to work?  I tried adding them to the xml file:

        <files>
                <filename>index.php</filename>
                <filename>templateDetails.xml</filename>
                <filename>css/mscarousel.css</filename>
      <filename>css/nav.css</filename>
      <filename>jquery-1.4.4.js</filename>
      <filename>jquery.msCarousel2.js</filename>
        </files>

But, it acts like they're not there.  I also tried FTP'ing them but it still doesn't seem to work.
0
 
LVL 12

Expert Comment

by:panagiotiss
ID: 34988778
it does not really matters all the other stuff

if you have the tag name as your template name then in the administrator under the template manager you will see your template

0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34988890
I think that question is too big to answer. I'd have to write the tutorial here.
0
 
LVL 14

Author Comment

by:EMB01
ID: 34989003
Please, is it written somewhere online?.. throw me a bone here...
0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34989148
Sorry in no way meant to give you a hard time, I figured that what you wanted was in that tutorial.

I don't have any specific resources that you couldn't find on Google yourself.

If it were me, I would open ja_purity index.php, see how that works, then apply those concepts to custom.

Would you like to give that a try?

0
 
LVL 14

Author Comment

by:EMB01
ID: 34989876
Sure, I'll download that file and look at it; but I just feel like I'm missing something small.  I already uploaded the files to the server and listed them in the XML file, so I don't know what else I could possibly need to do in order for the files to be recognized...
0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34990085
Make sure you have an article assigned to the front page, and modules assigned to "top" and to "bottom" positions.

Create directory OUTSIDE of your template area, in a work area, called mynewtemplate.

In that:

index.php
<?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
   xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/mynewtemplate/css/template.css" type="text/css" />
</head>
<body>hello
top<jdoc:include type="modules" name="top" />
component<jdoc:include type="component" />
bottom<jdoc:include type="modules" name="bottom" />
</body>
</html>


index.html
<html><body bgcolor="#FFFFFF"></body></html>







templateDetails.xml
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="template">
      <name>mynewtemplate</name>
      <version>1.0.0</version>
      <creationDate>02/26/2011</creationDate>
      <author>example.com</author>
      <authorEmail>you@example.com</authorEmail>
      <authorUrl>http://www.example.com.com</authorUrl>
      <copyright></copyright>
      <license>GNU/GPL version 2</license>
      <description>my new template</description>
<files>
            <filename>index.html</filename>
            <filename>index.php</filename>
            <filename>templateDetails.xml</filename>
      </files>
      <css>
            <filename>css/template.css</filename>
      </css>
      <positions>
            <position>top</position>
            <position>bottom</position>
      </positions>

</install>


css/template.css
body { background-color:blue; color:white;}



zip the directory at the command line using 7-zip's 7z.exe:

C:\xampp\htdocs\work>"c:\program files\7-zip\7z.exe" a mynewtemplate.zip .\mynew
template


0
 
LVL 14

Author Comment

by:EMB01
ID: 34991506
Thanks for your help.  The problem was a simple pathing issue; which I've resolved.  However, I'm still wondering about home page / article pages.  Do both exist in index.php?  For instance:

<?php
$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
        echo 'This is the home page';
} else {
        echo 'This is NOT the home page';
}
?>
0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34992159
The jdoc component spits out the article content. The content for the home page will display on the home page, the content for other menu items will display on their respective pages wherever the component jdoc tells it to. Determining the home page as you did there will not affect the content unless you say something like:

<?php
$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
       ?><jdoc:include type="component" /><?php
} else {
        echo 'This is NOT the home page and therefore you get no content';
}
?>
0
 
LVL 14

Author Comment

by:EMB01
ID: 34992518
It's just that I have two different layouts, one for the home page and one for the article pages.  How do I specify this so that joomla knows which to use?  Do you want me to open a new question for this question?
0
 
LVL 13

Expert Comment

by:joomla_php
ID: 34992547
yes
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Since I am currently running into this issue right now as I type this, I though I would share my experiences with moving a ModX Revolution site from one server to another.  It is not an easy task, but can be accomplished rather easily. The first …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to dynamically set the form action using jQuery.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now