| Modify an SMF theme for Joomla and Mambo - Intro |
|
|
Page 2 of 5 Removing the excess tagsThe first editing we do will be to remove the extra <html> <head> and <body> tags, as well as the excess header information. This will allow us to have a valid W3C XHTML web site.Open up index.template.php in your favorite text editor (I use Source Edit). Look for: function template_main_above() In the default theme it is on line 51. This is the function that displays the top part of the forum. Look for any decalarations underneath it. In the default theme we have one "global" line on line 53. After that, it starts to display the forum page headers, so that's the part we will want to cut out. Before line 55, add the following code: Side Note To keep your code clean, anything you are putting between these If statements (lines 57-137 in the demo) should be indented, but that's by no means critical. I won't mention this every time - do it if you like from here on out. Code: // check to see if the forum is running wrapped in mambo or standalone...
if (empty($_REQUEST['option'])){ Code: <body>'; Before the next line, add:Code: } // end of check if forum is wrapped so now it looks like:Code: <body>'; Please note, in some themes you may not have the '; at the end of the body line. This is necessary to close the echo command. If this is the case, you will need to add those in, and then add a line that says:} // end of check if forum is wrapped Code: echo ' to the next line after your "} // end of check if forum is wrapped" lineThere are some critical items in the headers you need, so, instead of the normal adjustment to the Joomla or Mambo template that we ask people to post (if you are using one of Orstio's bridges, version 1.1.14 or later, this isn't needed any more, so ignore this!), we'll be asking them to post this instead (just before the </head> statement in the Joomla or Mambo template): Code: <?php global $sc, $context, $settings; if (!defined('SMF')){ require ("administrator/components/com_smf/config.smf.php"); require ($smf_path."/SSI.php"); } $sc = &$context['session_id']; $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; mysql_select_db($mosConfig_db); echo ' <script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/script.js?beta4"></script> <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[ var smf_theme_url = "', $settings['theme_url'], '"; var smf_images_url = "', $settings['images_url'], '"; var smf_scripturl = "', $scripturl, '"; var smf_session_id = "', $context['session_id'], '"; // ]]></script>'; echo ' <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css?rc1" /> <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/print.css?beta4" media="print" /> <link rel="help" href="', $scripturl, '?action=help" target="_blank" /> <link rel="search" href="' . $scripturl . '?action=search" /> <link rel="contents" href="', $scripturl, '" />'; /* Internet Explorer 4/5 and Opera 6 just don't do font sizes properly. (they are big...) Thus, in Internet Explorer 4, 5, and Opera 6 this will show fonts one size smaller than usual. Note that this is affected by whether IE 6 is in standards compliance mode.. if not, it will also be big. Standards compliance mode happens when you use xhtml... */ if ($context['browser']['needs_size_fix']) echo ' <link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/fonts-compat.css" />'; // Show all the relative links, such as help, search, contents, and the like. echo ' <link rel="help" href="', $scripturl, '?action=help" target="_blank" /> <link rel="search" href="' . $scripturl . '?action=search" /> <link rel="contents" href="', $scripturl, '" />'; // If RSS feeds are enabled, advertise the presence of one. if (!empty($modSettings['xmlnews_enable'])) echo ' <link rel="alternate" type="application/rss+xml" title="', $context['forum_name'], ' - RSS" href="', $scripturl, '?type=rss;action=.xml" />'; // If we're viewing a topic, these should be the previous and next topics, respectively. if (!empty($context['current_topic'])) echo ' <link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" /> <link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />'; // If we're in a board, or a topic for that matter, the index will be the board's index. if (!empty($context['current_board'])) echo ' <link rel="index" href="' . $scripturl . '?board=' . $context['current_board'] . '.0" />'; if ($context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm')) { echo ' <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[ if (confirm("' . $txt['show_personal_messages'] . '")) window.open("' . $scripturl . '?action=pm"); // ]]></script>'; } ?> OK, we've hit a good spot to test this, so let's take out the extra </body> and </html> tags that we removed the opening tags for. They are down at line 398 - before that line, enter: Code: // check to see if the forum is running wrapped in mambo or standalone... Then, after line 402, enter:if (empty($_REQUEST['option'])){ Code: } // end of check if forum is wrapped So, now this part looks like this:Code: // check to see if the forum is running wrapped in mambo or standalone... if (empty($_REQUEST['option'])){ echo ' </body> </html>'; } // end of check if forum is wrapped With that part done, we should have a useable theme to test. Save this and upload it to your server. If you click the W3C XHTML 1.0 check button at the bottom of your forum, you shouldn't have any errors about extra head, body, or html tags, or about anything that should be in the header that is in the body. |
|||||||




