PDA

View Full Version : Template Control Panel for 2.0


Kier
15 Feb 2001, 15:32
UPDATED 28-02-2001

http://kier.3dfrontier.com/images/ktemplate.gif

This hack for vB2.0 Beta 2 will allow you to edit a single template set, or all of them at the same time, is dramatically less bandwidth-hungry than the current system, and allows quick searches through the templates by clicking in the <select> element and pressing a key; for example, if you want to find the 'header' template, just click in the select and press 'h' on your keyboard...

To install, follow the following instructions:

First, open the file forums/admin/adminfunctions.php and find the line


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

and replace it with this:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

This will allow the text of the <select> elements to be green or red in the templates page...

Next, open the file forums/admin/template.php and find the block of code that looks like this:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

and comment out the code between the { } like this:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Next, just after the first open brace, add a line so that the final code looks like this:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Next, find the section of text within the template.php code that looks like this:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

and replace it with this:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Finally, upload the attached file to your forums/admin/ folder, rename it to ktemplate.php and you're all ready to go.

19th Feb 2001 Additions:
The hack will now auto-select the last template you edited when you return to the list from submitting an edit, or adding a new custom template.
Cookie functions can be disabled for users who do not use output_buffering
Lots of minor bug fixes (this one actually works ;))
Please note: if you do not have output_buffering=On in your php.ini, you should comment out the '$usecookies' line at the top of ktemplate.php
28th Feb 2001 Additions:
I have now restored the original template.php's 'view original' functionality through the use of a little javascript. I have tested the script with browsers going back to Nutscrape 4.6, and they all work fine.
Just as an added extra, the hack now tells you how many global and custom templates you have...
28th Feb 2001 Additions: (more ;))
I just modified the code a little so that you can double-click in the menus for a default event:
Double-clicking a global template name will activate the 'add' function, giving you the option to create a customized template.
Double-clicking a customized/added template will open the edit page for the selected template.
Right-clicking a customized template will display the original template of that name. (Right-click functionality is IE only.)

15 Feb 2001, 15:41
Very nice...thank you so much!

15 Feb 2001, 16:03
Excellent hack!

--JAmes

15 Feb 2001, 16:16
Had to post another thank you for making my job easier....Excellent Hack!

15 Feb 2001, 16:48
A slight enhancement -

This is a new version of the file ktemplate.php, which now gives you the option to specify the size of the <select> items - just open up the code and find the lines at the top of the code that read:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Edit these numbers to taste - their meanings should be fairly self-explanitory. The defaults of 10,15 are what I have found to be most usable, but everything depends on the display resolution you are running.

Note: if you set the value to 1, the select menu will become a pop-up menu, rather than a list.

16 Feb 2001, 21:40
great hack man!
thanks alot :)

17 Feb 2001, 05:51
This is a great hack kier. It certainly speeds up template editing!

Now... if only you could select a default style/template set so that whenever you come into the edit screen it is selected. I've lost count how many times I've overwritten the default one by mistake! :eek:

We'll just never be satisfied. :)

By the way... I'd like to say thanks to the Jelsoft developers/designers of this template concept. It truly is the dogs bollox! There is nothing you can't change with this system. (although my wife isn't too happy with the amount of time I'm spending playing with it) :p

17 Feb 2001, 06:40
Great script! This makes template editing a lot easier, and now when you just edited a template, went to your forum, realized you didn't get it perfect and need to go back the that template you only go to the custom, and not sort through the whole list. Nice job.

Now i'm just wondering why i have 12 header templates.

17 Feb 2001, 20:36
Originally posted by fastforward
Now... if only you could select a default style/template set so that whenever you come into the edit screen it is selected. I've lost count how many times I've overwritten the default one by mistake! :eek:

Coming right up...

17 Feb 2001, 21:01
Okay, the hack will now remember which template set you were editing, until you click the [Edit a different template set] link.

Please note that this version of the script requires on of two things to be active:

You must either have GZip encoding turned on for your forum, or you must have

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

set in your php.ini configuration file. output_buffering is PHP4 only. Without one of these two items, the cookie-setting mechanism will fail, resulting in an error message.

Once the final version of vB2 is out, I will make the necessary modifications to the script to remove these requirements, but for now, it would require too much messing about with the code to make it worth my while.

17 Feb 2001, 21:12
You da man! :D

17 Feb 2001, 22:09
SUPER :)

I like to see it in Beta2 :)

Thanks..... ;)


cya

18 Feb 2001, 02:02
looks fab great improvement and much easier for people like me..i get this spat out at the top of the page though when i enter the templates in vbb admin
Warning: Cannot add header information - headers already sent by (output started at /home/doasquad/public_html/forums/admin/adminfunctions.php:17) in /home/doasquad/public_html/forums/admin/ktemplate.php on line 28
?? any ideas ?

18 Feb 2001, 02:25
Originally posted by pestilence
looks fab great improvement and much easier for people like me..i get this spat out at the top of the page though when i enter the templates in vbb admin
Warning: Cannot add header information - headers already sent by (output started at /home/doasquad/public_html/forums/admin/adminfunctions.php:17) in /home/doasquad/public_html/forums/admin/ktemplate.php on line 28
?? any ideas ?

Like I said above, if you don't use gzip compression for your boards, or you don't have output_buffering enabled in your php.ini, then the cookie function will cause the error you are getting.

I will post a new version with enhanced functionality in a few minutes, and a quick fix for this error.

18 Feb 2001, 05:13
I've updated the hack and posted new instructions at the top of this page.

18 Feb 2001, 06:10
Now if only microsoft was this efficient ..ahhh well i can dream...
kewl hack ..btw

18 Feb 2001, 09:10
can we see a screen shot?
pleasssssssssssssssssss?

18 Feb 2001, 09:55
http://www.vbulletin.com/forum/showthread.php?s=&threadid=8484

19 Feb 2001, 07:09
Originally posted by gekko
Now i'm just wondering why i have 12 header templates.

Did I mention...YEAH!! Why?? I have the same thing and no clue why???

19 Feb 2001, 07:11
Originally posted by Kier


Like I said above, if you don't use gzip compression for your boards, or you don't have output_buffering enabled in your php.ini, then the cookie function will cause the error you are getting.

I will post a new version with enhanced functionality in a few minutes, and a quick fix for this error.

I am getting this error after your latest update...(thanks for the hack btw, looks like I'll like it)...

Can you explain the meaning of the error, why it happens? Just so we can learn php while we're at it...

19 Feb 2001, 07:54
Originally posted by dwh
Can you explain the meaning of the error, why it happens? Just so we can learn php while we're at it...

Sure.

The script stores the $templatesetid of the template set you are working on in a cookie called $bbadmin_templatesetid.

Cookies are set through the PHP function setcookie(..), which sets the cookie by sending an HTTP header to your browser (like any other cookie-setting mechanism).

Here comes the problem: HTTP headers have to be sent to the browser before any display output has been sent to the browser. My cookie-setting system doesn't abide by that rule at the moment, as I tried to make as few modifications to the original template.php as possible, in order to make installation as easy as possible for all you guys and galls.

Therefore, when you run the script, the setcookie(..) function is actually called after PHP has output stuff to the browser, causing it to fail...

u n l e s s . . . ;)

you have output_buffering enabled in your php.ini file. This has the effect of preventing any output being sent to the browser until the PHP script has completely finished its execution. Therefore, the setcookie function is still valid, even though it's being called at an illegal point in the script. Using vB2's GZip compression system will have the same effect.

If you do not use output_buffering or gzip compression, or if you are using PHP3, then you should comment out the line in ktemplate.php that says $usecookies = "yes";. This will prevent the setcookie(..) function from being called.

Does that make sense to you?

19 Feb 2001, 08:01
Yes, thank you so much!

But I thot I set my gzip stuff to on in the options? Gotta double check that but I'm pretty sure...

19 Feb 2001, 08:17
Originally posted by dwh
I thot I set my gzip stuff to on in the options? Gotta double check that but I'm pretty sure...

To be honest, I haven't looked that closely at vBulletin's implementation of gzip compression... most implementations employ some form of output buffering, which would allow the cookie to be set, but if the control panel doesn't use the compression, or if vB's gzipping doesn't buffer the output, then setting output_buffering = On in php.ini is going to be the only way to allow the cookie to be set.

Once vB2 goes gold, I will revisit the hack and recode it so that the cookie can be set on any system.

19 Feb 2001, 15:41
You DO have to set output_buffering on in the php.ini. I tried just setting the vB gzip and the error was still apparent.

Works great with output buffering on though.

22 Feb 2001, 18:33
I installed this have into v2.0 and it works fine except for one error that appears at the top of each page. It is as follows:

Oops, php3_SetCookie called after header has been sent in ../ktemplate.php on line 46

What does this mean? How can I fix it?
I do have GZip enabled with a level of "1" compression.

28 Feb 2001, 05:02
very nice hack Keir, however I am missing two options from the original -

1) revert back to original
2) view original

The second in particualr was very helpful, when I screwed up something - or thought I did - and wanted to compare my edited template to the original.

28 Feb 2001, 05:16
1) revert back to original This functionality is still there, just click the 'remove' button. It does the same thing as the original 'revert to original' hyperlink. 2) view original Yes, this function is currently not available. If any javascript gurus can tell me how to read the yyy part from this: <option value=xxx>yyy</option> then I can put the functionality back in very easily... but I don't know how to pull out that info at the moment. I'm sure it's possible though.

28 Feb 2001, 05:25
If they click the view default button, run an extra query to get the name of the template known by its templateid and then just grab that template where templatesetid=-1.

28 Feb 2001, 05:33
Cheers Ed, but I've just found a way to do it without an extra query :)

Will post an updated hack in a short while once i've integrated it into the existing code :D

28 Feb 2001, 05:58
Updated version now available in the first post of the thread.

28 Feb 2001, 06:06
absolutely beautiful, thank you Kier!

28 Feb 2001, 13:43
does this work for beta2?

28 Feb 2001, 13:58
Yes.

28 Feb 2001, 14:10
I had to be sleeping I missed this one. :D

What a hack! Thanks.

28 Feb 2001, 14:26
Ok, I got it working but for some reason I get a parse error in template.php3 (had to rename to .php3 and edit all links in ktemplate to relfect this).

Parse error: parse error in template.php3 on line 487

Line 487 reads:
--------------
?>
--------------

Any ideas?

BTW, I also got an setcookie error, so I turned that option off in the ktemplate file. Is it ok to do that?

rgds,

28 Feb 2001, 16:26
Not sure about your parse error... are you sure you commented out all the right code?

As for the cookie thing, yes, just set the $usecookies variable to "no".

28 Feb 2001, 20:44
This hack makes it so much easier to edit the templates. Thanks a million Kier :)

01 Mar 2001, 00:03
I get lost here. I don't understand why you put ..... instead of the whole bit of code to look for and replace. :D

can you help me out?


Next, find the section of text within the template.php code that looks like this:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

and replace it with this:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

01 Mar 2001, 00:51
But here's what you do.
Find this:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


and replace it with this:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



Then, right below the line that begins $result, add this:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


(this should go between the $result line and the } else { line)

Hope this helps :)

01 Mar 2001, 12:49
I really like the rightclick view template function.

But I find it more useful if the original template would open in a new window.

To achieve this do the following

In ktemplate.php search for:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


and replace it with


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



That's it!

01 Mar 2001, 16:16
A hack for a hack? Is that a first? ;)

I like the idea, and I'll integrate similar code into the next release.

01 Mar 2001, 17:52
keir,

Will my templates remain edited the way I edit them if/when I upgrade to the next version of VB2.0 ?

01 Mar 2001, 18:15
Originally posted by evoir
Will my templates remain edited the way I edit them if/when I upgrade to the next version of VB2.0 ?

All I have done is change the interface to the template control panel. The work that is done behind the scenes is the same.

So yes, you can upgrade to the Beta 3 (or whatever comes out next) whenever you like and all your templates will be just as though you edited them with the original control panel.

02 Mar 2001, 14:55
awsome hack. really good job

06 Mar 2001, 01:55
Excellent!!!
I must have missed this one a well, great hack man.
This is a must for the final version!

09 Mar 2001, 08:10
Kier, very very nice work. I have used your hack since vB v2.0 alpha and just now applied it to v2.0 beta 3. Working great so far.

Fryzid - I liked your hack of the hack that opens into a new window, however, there is a rouge space at the end of your line in height. he ight=320 with the space removed it works perfect.

Kier, you may want to edit your first post again, and fix the truncated lines that evior pointed out. I will bet a lot of people will not see tubedogg's post of the correct lines, and never get this working.

Thanks a ton for the excellent hack.

Cheers!

09 Mar 2001, 19:33
NgtCrwlr The space is not there when I try to edit my post and I didn't post the line with a space in it.
Don't know what's wrong there. :(

09 Mar 2001, 22:08
I just experimented with that line and found that if you add one space after any of the comma's it will work. It might have something to do with vB long word wrap, however, I have my word wrap set at 100 and the problem space is showing up at character 232, so it doesn't appear to be word wrap.

Starting at resizeable=yes I put spaces after each of the comma's and it displays fine.

http://www.mis-forums.com/vbbs/showthread.php?goto=lastpost&threadid=2977

Maybe someone can shed a little light on this?

Cheers!

10 Mar 2001, 14:13
Mouarfffff
You must go in the dev team lol :)

10 Mar 2001, 14:19
To implement the right-click default view thingy, find this in ktemplate.php:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

and replace with this:

Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

:)

10 Mar 2001, 15:00
This might be because of output buffering, or did I do something wrong? I'm getting URL's like:

http://127.0.0.1/forum/admin/?s=&s=08ca21fddf4a988afb7d91d5d7717ea7

I haven't had a chance to look at the code, but I'm guessing it's because I don't have output buffering enabled.

Works great though...

TechTalk
14 Apr 2001, 03:42
PLEASE ADD TO 2.1 :)

~Chris

Kier
14 Apr 2001, 04:12
We are looking into ways of integrating Ed's 'expanders' code with my form-based template CP for 2.1

bira
14 Apr 2001, 18:22
for some reason, your hack loads a hell of a lot faster and is a lot easier to use, than the current Templates system.

But, for some reason I can't get your hack to integrate with vB2b5.

Suggestions?

Kier
15 Apr 2001, 08:01
My hack will load a lot faster than the default template CP for one simple reason: there's a lot less HTML to download.

In the standard editor, for every single template you have this code:

<li><font color="red">headinclude</font> <a href="template.php?action=edit&templateid=4776&group=">[edit]</a> <a href="template.php?action=remove&templateid=4776&group=">[revert to original]</a> <a href="template.php?action=view&title=headinclude">[view original]</a></li>

(whew!)

... whereas the same template in my editor will have only this code:

<option value="4776" style="color:red">headinclude</a>

... due to the fact that the actions and sessionhash are all handled by the <form>.

The massive wall of HTML in the default editor was the first reason why I made the hack.

auto
15 Apr 2001, 19:28
so it's going to be integrated in vB right?

Kier, i got an idea :)
don't release hacks, just stick the code in vB.
So we can download "vB 2.0 Kier version" :p

JoshFink
02 Aug 2001, 18:28
Great hack.. Is there any update on this for 2.0.3?

Thanks,

Josh

DarkReaper
07 Aug 2001, 03:48
How can I install this on 2.0.3?

DarkReaper
11 Aug 2001, 03:30
Well I just took a look at it and everything is there for 2.0.3. Just upload the file, uncomment the include statement for ktemplate.php, and comment out the rest and you're set!

One thing I'd love to see though:

The ability to have all template sets use templates that were modified on the default set. For example, if I modify postbit on the default template, I could have all my other templates use the modified postbit, instead of having to modify it on everything.

LuBi
26 Aug 2001, 19:33
Hack looks great, sounds good dark reaper I'd like to see the same. Like the default is the standard. So this installs just the same to 2.0.3 without editing different files then specified?

LuBi
26 Aug 2001, 19:39
Can this hack work with this one? Preview and copy buttons for Edit Template (http://www.vbulletin.com/forum/showthread.php?s=&postid=161146#post161146)

Dakota
06 Sep 2001, 05:50
I get this error. I am using vB 2.0.3

Warning: Cannot add header information - headers already sent by (output started at F:\*\adminfunctions.php:18) in F:\*\forum\admin\ktemplate.php on line 47

Mike Gaidin
06 Sep 2001, 22:02
Try going into your control panel and setting your GZIP output to Yes.

Dakota
07 Sep 2001, 19:19
That didn't work.

DemiNeo0101
30 Mar 2002, 18:17
omg omg omg i love you i love you!!!!!

*clicks install*

shri
08 Apr 2002, 07:31
I am assuming this is usable with 2.2.5?