PDA

View Full Version : Return to Edit Template page after saving


Chen
22 Sep 2001, 13:53
This is far from being a hack, so I figured I should post it here.
Probably be moved though... :)

Anyway, this adds an option to the Edit Template page for returning to the same page or not.
If you select yes, then the template will be saved and you will be sent back to the editing page.
If you select no (default), then you will be sent to the main template list.

I wanted this cuss I sometimes I just edit a template over and over and over again, and loading the list again is quite a pain you-know-where. ;)

Hopefully others will also find this helpful.


All changes are done to template.php (admin folder)!

Find this code:
makehiddencode("group", "$group");
(second time it appears, not first time!)
and right above add this:
makeyesnocode("Return to this page?","return",0);

Now replace this:
echo "<p>Done!</p>";
$action="modify";
$expandset=$templatesetid;
with
echo "<p>Done!</p>";
if ($return) {
$action="edit";
} else {
$action="modify";
$expandset=$templatesetid;
}
And last but not least move this block:
// ###################### Start do update #######################
if ($HTTP_POST_VARS['action']=="doupdate") {
// a few lines of code here
}
a few lines up, namely right before this:
// ###################### Start edit #######################
if ($action=="edit") {

And that's it.
If you want the default selection to be yes (not recommended - for obvious reasons), change the 0 to 1:
makeyesnocode("Return to this page?","return",0);

That's it, hope you enjoy this. :)

Please note that this is only and only for edited template.
For original templates the option will not show up, because well, it's bit more complex. :p

I added a screen shot if you still don't get this. ;)

eva2000
22 Sep 2001, 14:02
i like this one :D

Mike Gaidin
22 Sep 2001, 14:10
Me too. :D Good one!

Goldfinger
22 Sep 2001, 14:12
Again another great hack by FireFly :D.

Thomas P
22 Sep 2001, 17:29
Veeery helpful and -although never spoken out ;)- long awaited :D
Pleeeease make it a standard feature, vb folks :)
Thanks FireHacker :p
-Tom

FWC
22 Sep 2001, 20:55
Very nice, Firefly! Thank you. :D

Alien
23 Sep 2001, 09:56
Very helpful, thanks bunches!

:D

Chen
23 Sep 2001, 11:09
Heh, didn't think people will really need/like this. :)

Let's have a vote, do you want support for original templates?
I think it's useless, cuss if you're gonna be editing a template a lot of times it will only be original when you first edit it.

Alien
23 Sep 2001, 13:00
Really don't need that support myself. :)

This is great, it's saving me from carpal tunnel!

holev
23 Sep 2001, 14:43
i did everything right and selected Yes but it wont return to the same page.

Delu
05 Oct 2001, 09:39
i did all as u wrote and didn't work...
when i edited a template i checked "yes" and nothing new hpanned...it moved me to the main templates page...

Chen
05 Oct 2001, 11:07
Did you add what I said in this block?
// ###################### Start edit #######################
if ($action=="edit") {
// blbala
}

FWC
02 Nov 2001, 07:24
Firefly, does this work in 2.2.0? I had it installed in 2.0.3. I've tried adding it twice to the new version. I'm not getting anything. I'm probably just doing something wrong. Please tell me it works so I can send myself to the dumbass room. :)

Chen
02 Nov 2001, 13:32
Yup, works great. :)

Lesane
02 Nov 2001, 17:28
Thanks for this nice & neat hack FireFly ;)

silence
02 Nov 2001, 21:08
I so needed this. lol

FWC
02 Nov 2001, 21:40
Originally posted by FireFly
Yup, works great. :) OK, I just returned from the dumbass room. I looked at my 2.0.3 template.php and the new 2.2.0 version. I had to move the makeyesnocode line up one. The javascript runs to make the box before it saw the line. It works now. I can't live without that thing. :D

SirSteve
04 Nov 2001, 06:52
This is what mine looks like:

// ###################### Start do update #######################
if ($HTTP_POST_VARS['action']=="doupdate") {

So, I cannot move this block... ?

Chen
04 Nov 2001, 14:00
Why not?
That's exactly what you should have.

SirSteve
05 Nov 2001, 07:02
This is what the hack says:

// ###################### Start do update #######################
if ($HTTP_POST_VARS['action']=="doupdate") {
// a few lines of code here
}

-------------------------------------------------

This is mine:

// ###################### Start do update #######################
if ($HTTP_POST_VARS['action']=="doupdate") {


$DB_site->query("UPDATE template SET templatesetid=$templatesetid,title='".addslashes("$title")."',template='".addslashes("$template")."' WHERE templateid=$templateid");

echo "<p>Done!</p>";
if ($return) {
$action="edit";
} else {
$action="modify";
$expandset=$templatesetid;
}
}

----------------------------------------------------------

This is correct?

Chen
05 Nov 2001, 12:56
By this:
// a few lines of code here
I mean there are some lines of code there I didn't want to specify.
So yes, that's correct.

amykhar
05 Nov 2001, 15:42
Firefly,

in 2.2, this code:


makehiddencode("group", "$group");


seems to be in two places. The first place puts the checkbox in the unedited templates ( but it doesn't work, as you said it wouldn't)

the second place is the one you want.

Amy

SirSteve
05 Nov 2001, 19:56
Working great on v2.2.0 !

Thanks!

Chen
05 Nov 2001, 20:49
Thanks Amy, I edited the first post (I did it earlier but didn't have the time to reply, sorry). :)

snyx
10 Nov 2001, 19:36
love this little hack :D

LuBi
12 Nov 2001, 06:44
I keep having trouble posting whole edited .php files. I think it's my software to edit them I am using Editplus 2 but it must be adding something to the end of the document because I'll get a Parse error at the last line of the document. Like I keep getting Parse Error like line 713 with this hack. Can anyone help me?

FWC
12 Nov 2001, 07:57
Originally posted by LuBi
I keep having trouble posting whole edited .php files. I think it's my software to edit them I am using Editplus 2 but it must be adding something to the end of the document because I'll get a Parse error at the last line of the document. Like I keep getting Parse Error like line 713 with this hack. Can anyone help me? I use EditPlus2. I'm not having any problem. Make sure you back the cursor up to the last > if there is anything at the bottom of the file. Also, make sure you have the PHP template and settings and syntax installed in Preferences > Files.

LuBi
12 Nov 2001, 08:06
What settings do you use, I'm not sure what exactly it's doing but I get a parse error with any code I edit on the last line, I guess could you explain everything out a bit more. :confused: thanks again ;)

LuBi
12 Nov 2001, 21:22
This is what the screen looks like, I believe that little thing after the cursor is what causes my trouble. How can I get rid of that?

https://www.vbulletin.org/forum/

LuBi
12 Nov 2001, 22:55
Got everything working now, great hack as usual thanks again!

FWC
12 Nov 2001, 23:04
Originally posted by LuBi
Got everything working now, great hack as usual thanks again! What was the solution with EditPlus2?

LuBi
12 Nov 2001, 23:44
Jezz :o lol thought I could get away without anyone asking. I guess I was doing somehting wrong with this hack and another but it must have been my own error :eek: I feel bad but I don't know what i changed if I did Textpad still doesn't work but EditPlus does so I've already installed 5 hacks with 4 more to come, then the customization begins.

My only worry now is that 2.2.0 isn't that last update someone told me it has bugs, so I dunno why I'm adding hacks unless the update is small and doesn't change a lot... If it does change to much then I give up :o

FWC
13 Nov 2001, 00:52
Originally posted by LuBi
My only worry now is that 2.2.0 isn't that last update someone told me it has bugs, so I dunno why I'm adding hacks unless the update is small and doesn't change a lot... If it does change to much then I give up :o LOL, I'm glad you got things working. The upgrade is just a bug fix. Some people are having problems. I probably won't upgrade. My system works fine as is.

Stretchr
20 Jan 2002, 18:53
Started laughing at this post but when I looked up, I found I was one floor below FWC. Persevered through my ignorance and the third time, I apparently followed the directions and:

What A Great Hack! Thanks for another one, FireFly!
:supwink:

Originally posted by Lubi
OK, I just returned from the dumbass room. I looked at my 2.0.3 template.php and the new 2.2.0 version. I had to move the makeyesnocode line up one. The javascript runs to make the box before it saw the line. It works now. I can't live without that thing. :D

Lucky
21 Jan 2002, 12:31
Very impressed.

Thanx again old buddy.

Jawelin
21 Jan 2002, 16:34
Nice, Chen!

Just something: when I edit twice the same template and save it with the 'return to this...' = on, I get in the body of textarea Array instead of the full template text I just saved.

Just seems it looses some brakets value ...
Note: new template is actually saved as 'Array', because if I exited and re-edit, this text is the only existing within body (and even into db)... :(

I dupe-checked the hack just applied and seems having followed your instructions literally.

Thanks a lot.
Bye

Chen
22 Jan 2002, 10:13
Jawelin, that's odd, I've been using this hack for 4 months already and never faced that problem! Do you mind sending me your template.php file by e-mail, so I could have a look and try it out? Thanks. :)

Jawelin
25 Jan 2002, 13:38
It's coming.
Thanks a lot.

P.S.: I think made some mistake near 'few rows below' ... ;)

DelusionalMind
26 Jan 2002, 01:05
nice :)

will be installing in a few :)

Sparkz
26 Jan 2002, 01:35
Great little hack... Really useful.

Kept trying to make this work over and over again on my testboard without success - until I descovered I was actually editing the file on the live site... that's what you get for hacking at 3.30 in the morning... *sigh*

Jawelin
29 Jan 2002, 16:21
Originally posted by FireFly
Jawelin, that's odd, I've been using this hack for 4 months already and never faced that problem! Do you mind sending me your template.php file by e-mail, so I could have a look and try it out? Thanks. :)
Hi, Chen. I sent the email some days ago and would just to have an ack if your address was right.
Thanks again.
Bye

Jawelin
21 May 2002, 18:56
As I couldn't manage to make this hack working 'as is', I created a workaround to obtain the same results.
Here they are, if - as read - someone else got the same problems.

Add

//HACK: Return to edit page after saving template
makeyesnocode("Return here","comeback",1);
makehiddencode("prevaction", "$action");
//HACK: Return to edit page after saving template

wherever you want to return to (I mean, right before the 'save changes' button in edit section)...
Later, in the 'doupdate' section, add at the end:


//HACK: Return to edit page after saving template
if ($comeback and $prevaction) {
cpredirect("template.php?s=$session[sessionhash]&action=$prevaction&templateid=$templateid",0);
}
//HACK: Return to edit page after saving template


It should work... :eek:
Thanks to Chen for the idea.

Birdie501
22 May 2002, 10:03
Thanks, really good and saves a lot of clicks!

Hobbes
05 May 2003, 02:20
I got the array error also....could anyone post a fix for it? cuz I R confused and it screwed up my forumhome :(

gmarik
09 Jun 2003, 14:22
It shows Done! and does not redirects bakc to edit mode on 2.3 :pirate:

PixelFx
08 Sep 2003, 23:47
one, Very cool, just installed it on vb 2.3.2 works great. INSTALLED ;)

question?? :)

how would I get this to work with filburt1

Quick Edit Templates - hack ?