TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 343
  • Total: 343

Replace blocks TPcollapse/TPexpand buttons

Started by whoesa, April 12, 2008, 01:03:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

whoesa

I can't seem to figure out how to replace these buttons with custom ones.

- First i tried to add a "tinyportal" folder in the images folder of the custom theme but that didn't work. It still used the images from default theme.

- Then i tried adding this line in index.template file...:
$settings['tp_images_url'] = $settings['images_url'] . '/tinyportal';
...that seemed to work at first. But the moment you click the blocks TPcollapse/TPexpand button, it then changes to collapse/expand.gif from images folder. (Happens on this site as well.)

Not sure why it behaves like this but perhaps it's something in the script in TPBlocks.template file?
// the upshrink routine for blocks
$tid=time();
echo '</div>
<script language="Javascript" type="text/javascript"><!--
function toggle( targetId )
{
var state = 0;
var blockname = "block" + targetId;
var blockimage = "blockcollapse" + targetId;

if ( document.getElementById ) {
target = document.getElementById( blockname );
if ( target.style.display == "none" ) {
target.style.display = "";
state = 1;
}
else {
target.style.display = "none";
state = 0;
}

document.getElementById( blockimage ).src = smf_images_url + (state ? "/collapse.gif" : "/expand.gif");
var tempImage = new Image();
tempImage.src = "'.$scripturl.'?action=tpmod;upshrink=" + targetId + ";state=" + state + ";" + (new Date().getTime());

}
}
--></script>';


I tried to change a few things without success.

Jpg

#1
Are you using Expand/Collapse or TPCollapse/TPExpand?

You might have to rename the gifs.

edit-
Change
document.getElementById( blockimage ).src = smf_images_url + (state ? "/collapse.gif" : "/expand.gif");

to

document.getElementById( blockimage ).src = smf_images_url + (state ? "tinyportal/TPcollapse.gif" : "tinyportal/TPexpand.gif");

It points to -> Theme/YourTheme/images/
Add a -> tinyportal/ to determine your directory.

whoesa

That's one of the things i tried already but didn't work.

TP 0.98 uses collapse/expand.gif for the blocks. TP 1.0 uses TPcollapse/TPexpand.gif and it shows these after i added that line in my first post. Only when you click them, they go back and use collpase/expand.gif again until you refresh the page.

Like i said, the same happens on this site. For example look at BZ14 theme and expand a block.

Jpg

Did you try replacing the code as I pointed above?

whoesa


Jpg

I don't understand. You said you put-
$settings['tp_images_url'] = $settings['images_url'] . '/tinyportal';

So now all the images are pointing to-
Themes/YourTheme/images/tinyportal/

So now the image is for collapsing the block is-
Themes/YourTheme/images/tinyportal/Tpcollapse.gif

When you click it goes back to-
Themes/YourTheme/images/expand.gif and
Themes/YourTheme/images/collapse.gif

Is this all correct?

So basically you have to change the filename + directory?

Open TBlocks.Template.php
Change:
(state ? "/collapse.gif" : "/expand.gif");
to-
(state ? "tinyportal/TPcollapse.gif" : "tinyportal/TPexpand.gif");
It should point to your folder + file.

What could possibly be wrong is that you have javascript in your theme's index.template.php that could be interfering with the javascript in the TBlocks.template.php.


whoesa

Trust me, i don't understand as well lol.  :uglystupid2:

If i don't add that line in index.template file, it just takes the images from default theme, no matter what.

QuoteSo now all the images are pointing to-
Themes/YourTheme/images/tinyportal/

So now the image is for collapsing the block is-
Themes/YourTheme/images/tinyportal/Tpcollapse.gif

When you click it goes back to-
Themes/YourTheme/images/expand.gif and
Themes/YourTheme/images/collapse.gif

Is this all correct?

Correct.

QuoteSo basically you have to change the filename + directory?

That's what i thought as well but it's not working. It shows TPcollapse.gif but when clicked, all buttons disappear.

Jpg

Do you want me to take a look for you?
Set me up an account and I'll be glad to help you personally.

whoesa

All my testsites are on a local server on my pc but thanks anyway. I'll just wait till Bloc has the time to check and answer this.

Jpg

LOL MY BAD I forgot the slash["/"] Ahahahaha! :2funny:


Try this php in my attachment[I tested it and it works]-

This website is proudly hosted on Crocweb Cloud Website Hosting.