TinyPortal

Development => Feedback => Bugs/Errors => Topic started by: whoesa on April 12, 2008, 01:03:27 PM

Title: Replace blocks TPcollapse/TPexpand buttons
Post by: whoesa on April 12, 2008, 01:03:27 PM
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.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Jpg on April 12, 2008, 03:45:21 PM
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.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: whoesa on April 12, 2008, 05:15:29 PM
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.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Jpg on April 12, 2008, 05:27:32 PM
Did you try replacing the code as I pointed above?
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: whoesa on April 12, 2008, 05:31:21 PM
Quote from: Bikken on April 12, 2008, 05:15:29 PM
That's one of the things i tried already but didn't work.

;)
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Jpg on April 12, 2008, 05:40:45 PM
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.

Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: whoesa on April 12, 2008, 06:11:56 PM
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.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Jpg on April 12, 2008, 06:18:50 PM
Do you want me to take a look for you?
Set me up an account and I'll be glad to help you personally.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: whoesa on April 12, 2008, 06:29:58 PM
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.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Jpg on April 12, 2008, 06:46:18 PM
LOL MY BAD I forgot the slash["/"] Ahahahaha! :2funny:


Try this php in my attachment[I tested it and it works]-
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: whoesa on April 12, 2008, 07:17:28 PM
Omg how could i miss that one.  ???  Is it possible to be drunk without drinking alcohol?

Anyway, thx for pointing it out.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Jpg on April 12, 2008, 07:23:35 PM
Lol, I don't think you can...hahaha...
And No problem Bikken. I'm here to help.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Gidget on April 13, 2008, 10:45:16 AM
Many thanks Bikken and Jpg for raising, and solving, the same problem that I had  ;D

Gidget
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Jpg on April 13, 2008, 04:16:32 PM
Your welcome Gidget.

Bloc is going to have to fix that error in the future.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: bloc on April 14, 2008, 01:27:05 PM
Yes, I do lol. So..after a quick read, what was the error actually? a typo?
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: whoesa on April 14, 2008, 01:44:09 PM
Well, to make them work properly in custom themes, it was needed to add this line in index.template file:

$settings['tp_images_url'] = $settings['images_url'] . '/tinyportal';

and change the image url in the script in TPBlocks.template file from:

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");

After these changes, everything works fine.   :D
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Jpg on April 14, 2008, 03:31:51 PM
That would point to your theme directory Bikken not the default theme directory.
I'll look into this for a fix.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: whoesa on April 14, 2008, 04:12:49 PM
Yea and that was the whole point of me starting this topic. I tried to find out how i could point a custom theme to it's own "tinyportal" folder and TPcollapse/TPexpand button instead of defaults one.

I did this fix in 4 custom themes and all are working error less. 
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Jpg on April 15, 2008, 02:55:45 AM
Okay I decided to take 5 minutes to fix this.

Here's the code needed to fix the bug forever-

In TPblocks.template.php:

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

Replace with-

                  document.getElementById( blockimage ).src = "' .$settings['tp_images_url']. '" + (state ? "/TPcollapse.gif" : "/TPexpand.gif");


----

I guess all you have to do is add this code to your themes now Bikken for customization-
$settings['tp_images_url'] = $settings['images_url'] . '/tinyportal';
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: rand12om on May 12, 2008, 06:45:37 PM
Where exactly should I put the $settings['tp_images_url'] = $settings['images_url'] . '/tinyportal'; ?

Placing it in the index.template does fix the collapse button problem, but completely messes up the buttons in Articles adminpage and same for blocks. I mean, it displays text instead of buttons. What am I doing wrong?
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: IchBin on May 12, 2008, 06:51:05 PM
If you place that code in your index.template.php file, then you also need to copy ALL of the tinyportal images from the default theme to your theme. You're probably missing the images, which is why its displaying the text instead.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: rand12om on May 13, 2008, 12:12:47 PM
Yes, thats it. Thanks :)
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: confuzed on May 26, 2008, 11:10:48 PM
Quote from: Jpgâ,,¢ on April 15, 2008, 02:55:45 AM
Okay I decided to take 5 minutes to fix this.

Here's the code needed to fix the bug forever-

In TPblocks.template.php:

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

Replace with-

                  document.getElementById( blockimage ).src = "' .$settings['tp_images_url']. '" + (state ? "/TPcollapse.gif" : "/TPexpand.gif");


----

I guess all you have to do is add this code to your themes now Bikken for customization-
$settings['tp_images_url'] = $settings['images_url'] . '/tinyportal';


ah I just found this solution :)

does it matter whereabouts in the index.template file you add the code above?
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: IchBin on May 27, 2008, 02:58:48 AM
template_init() is where you can do it.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: confuzed on May 27, 2008, 09:08:54 AM
// Initialize the template... mainly little settings.
function template_init()
{
global $context, $settings, $options, $txt;

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

/* What document type definition is being used? (for font size and other issues.)
'xhtml' for an XHTML 1.0 document type definition.
'html' for an HTML 4.01 document type definition. */
$settings['doctype'] = 'xhtml';

/* The version this template/theme is for.
This should probably be the version of SMF it was created for. */
$settings['theme_version'] = '1.1';

/* Set a setting that tells the theme that it can render the tabs. */
$settings['use_tabs'] = true;

/* Use plain buttons - as oppossed to text buttons? */
$settings['use_buttons'] = true;

/* Show sticky and lock status seperate from topic icons? */
$settings['seperate_sticky_lock'] = true;
}


here is my template_init() function, where specifically should it go?

Thanks
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: IchBin on May 28, 2008, 12:40:22 AM
Anywhere in there. Don't be afraid to try things or you'll never learn mate.
Title: Re: Replace blocks TPcollapse/TPexpand buttons
Post by: Riryoku on June 03, 2008, 08:53:51 AM
Oh! Thx.
That's cool.  ;D