Page 1 of 1

[solved]Site header question

Posted: Sun Sep 26, 2010 7:25 pm
by EoinDubh
I am migrating a site from phpWebsite to CMSMS. The original site is at http://sstsng.com/.
If you look at the site and refresh the page you will notice that the photo changes with each refresh. The new site is at http://sstsmg.com.sscms/ and I would like to be able to do the same thing with this site. However I am having trouble getting it to work. I am fairly good with html, php and css but have not worked much with smarty before. It seems that wherever I place the code it has no effect on the page. The code from the old site is

Code: Select all

</__body>

<a href="."></a>
<table>
<tr><td><img src="{THEME_DIRECTORY}/images/poweredby.jpg" alt="SSTS logo" border="0" />
</td><td><img src="{THEME_DIRECTORY}/images/spacer_100px.jpg" alt="spacer" border="0" />
</td><td>
<img src="{THEME_DIRECTORY}images/header/rotator.php" align="middle" alt="Auto Images" />
</td><td><h2>The Sorry Safari Touring Society</h2><br /><h3> - A gathering of MG enthusiasts</h3></td></tr>
</table>
I would guess that it should go in the defaultTheme.php for the site in this section

Code: Select all

{
	echo '<div><p class="logocontainer"><img src="themes/default/images/logo.gif" alt="" /><span class="logotext">'.lang('adminpaneltitle').' - '. $this->cms->siteprefs['sitename'] .'    '.lang('welcome_user').': '.$this->cms->variables['username'].'</span></p></div>';
        echo "<div class=\"topmenucontainer\">\n\t<ul id=\"nav\">";
        foreach ($this->menuItems as $key=>$menuItem) {
        	if ($menuItem['parent'] == -1) {
        	    echo "\n\t\t";
        		$this->renderMenuSection($key, 0, -1);
        	}
        }
bui I have not been able to get it working so far.

Any suggestions?

Re: Site header question

Posted: Mon Sep 27, 2010 6:55 am
by Peciura
Personally i store own themes on "/uploads/themes". In your case it could look like this

Code: Select all

{root_url}/uploads/themes/default/images/logo.gif
For logo i would use CSS:

Code: Select all

<a id='logo' title='{sitename}'/>

Code: Select all

a#logo{
position:absolute;
top:148px;
left:165px;
z-index:-5;
color:#FFF;
background: transparent url(/uploads/themes/default/images/logo.gif) no-repeat scroll -318px -211px;
width:250px;
height:250px;
}
Do not forget you can use smarty in CSS if needed
background: transparent url([[root_url]]/uploads/themes/default/images/logo.gif)

Re: Site header question

Posted: Mon Sep 27, 2010 7:59 am
by uniqu3
For the random image you could use something like this in your Template "Layout->Template->Yout Template"
{math equation='rand(1,5)' assign="imgnumber"} {*calculating numbers from 1 to 5 *}
{assign var="random_image" value="uploads/yourtemplate/yourimagename`$imgnumber`.jpg"} {* adds the random number to the image name *}
And where image should be displayed:
or simply:
And in your /uploads/yourtemplate folder you simply save images like:
yourimagename1.jpg
yourimagename2.jpg
yourimagename3.jpg

Re: Site header question

Posted: Sat Oct 09, 2010 3:00 am
by EoinDubh
For the site that I posted about, we decided to go ahead with the updated site without the changing graphics. However, as I have several sites that I am moving to CMSMS, the same issue exists with a couple of them.

I think that I was not clear enough in my question. I have the logo working. That was easy. What I am having trouble with is the second part of the header which is most easily explained by looking at the site that I am converting. It is at http://clan-donald-usa.org and it places a photo at the top right of each page that changes every time the page is refreshed. The code that does this is:

Code: Select all

<img src="{THEME_DIRECTORY}images/header/rotator.php" align="middle" alt="Clan Donald Images" />
. I realize that the path needs to change as it is from the old site. In the header directory are the photos and some javascript which changes the images randomly. If you look at the new site http://clan-donald-usa.org/CDCMS/ you will see the logo at the left and the site name graphic to the right. Where I am having trouble is in where to put the code to display the images.

Thanks

Re: Site header question

Posted: Sat Oct 09, 2010 10:26 am
by Peciura
The easiest way was just described by uniqu3.
Other options is to use image rotator plugin (there are some of them on forge), like "Random Image Selector" or even modules like Gallery or Album.

I could only extend Uniqu3 template. In this template you do not need to rename files  on directory.
{assign var='header_images' value='uploads/relative/path/to/header/images/*.*'|glob}
{capture assign='equation'}rand(0,{$header_images|@count}-1){/capture}
{math equation=$equation assign='imgnumber'}
{if !empty($header_images)}

{/if}

Re: Site header question

Posted: Sat Oct 09, 2010 11:15 am
by spcherub
I second (third?) the suggestions made by the previous responders. Now that you are working within the CMSMS framework, you should try and use existing extensions and modules that can do what you need, instead of relying on your own, stand-alone scripts. Of course, if you don't find a module, extension or workaround that meets your need, you could write one, but it should be done using the guidelines for working within the framework.

If you still want to use your rotator.php script you will need to put it outside the CMSMS /uploads directory. So if CMSMS runs from /cms/ then create a folder /cms/custom and copy your script here, and make sure to update references (within the script) to source images as necessary. Then update your calls in your template to say src="/custom/rotator.php".

This way you can run your custom script and also protect it from being inadvertently clobbered during a future upgrade.

But... try to get this done using standard methods outlined by other posters first, before resorting to your custom script.

Hope that helps.

Sanjay

Re: [solved]Site header question

Posted: Sun Oct 17, 2010 2:01 pm
by EoinDubh
Thanks for the pointers. I am working on trying to get up to speed on the way that the framework functions. For now I am using just plain text but am also working on usint existing modules to accomplish what I want to do.