PDA

View Full Version : Return to Edit Template page after saving


Admin
09-21-2001, 10:00 PM
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
09-22-2001, 12:02 PM
i like this one :D

Mike Gaidin
09-22-2001, 12:10 PM
Me too. :D Good one!

Goldfinger
09-22-2001, 12:12 PM
Again another great hack by FireFly :D.

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

FWC
09-22-2001, 06:55 PM
Very nice, Firefly! Thank you. :D

Alien
09-23-2001, 07:56 AM
Very helpful, thanks bunches!

:D

Admin
09-23-2001, 09:09 AM
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
09-23-2001, 11:00 AM
Really don't need that support myself. :)

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

holev
09-23-2001, 12:43 PM
i did everything right and selected Yes but it wont return to the same page.

Delu
10-05-2001, 07:39 AM
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...

Admin
10-05-2001, 09:07 AM
Did you add what I said in this block?
// ###################### Start edit #######################
if ($action=="edit") {
// blbala
}

FWC
11-02-2001, 05:24 AM
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. :)

Admin
11-02-2001, 11:32 AM
Yup, works great. :)

Lesane
11-02-2001, 03:28 PM
Thanks for this nice & neat hack FireFly ;)

silence
11-02-2001, 07:08 PM
I so needed this. lol

FWC
11-02-2001, 07:40 PM
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
11-04-2001, 04:52 AM
This is what mine looks like:

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

So, I cannot move this block... ?

Admin
11-04-2001, 12:00 PM
Why not?
That's exactly what you should have.

SirSteve
11-05-2001, 05:02 AM
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='".addsla shes("$template")."' WHERE templateid=$templateid");

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

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

This is correct?

Admin
11-05-2001, 10:56 AM
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
11-05-2001, 01:42 PM
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
11-05-2001, 05:56 PM
Working great on v2.2.0 !

Thanks!

Admin
11-05-2001, 06:49 PM
Thanks Amy, I edited the first post (I did it earlier but didn't have the time to reply, sorry). :)

snyx
11-10-2001, 05:36 PM
love this little hack :D

LuBi
11-12-2001, 04:44 AM
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
11-12-2001, 05:57 AM
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
11-12-2001, 06:06 AM
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
11-12-2001, 07:22 PM
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://vborg.vbsupport.ru/

LuBi
11-12-2001, 08:55 PM
Got everything working now, great hack as usual thanks again!

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

LuBi
11-12-2001, 09:44 PM
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
11-12-2001, 10:52 PM
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
01-20-2002, 04:53 PM
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
01-21-2002, 10:31 AM
Very impressed.

Thanx again old buddy.

Jawelin
01-21-2002, 02:34 PM
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

Admin
01-22-2002, 08:13 AM
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
01-25-2002, 11:38 AM
It's coming.
Thanks a lot.

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

DelusionalMind
01-25-2002, 11:05 PM
nice :)

will be installing in a few :)

Sparkz
01-25-2002, 11:35 PM
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
01-29-2002, 02:21 PM
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
05-21-2002, 04:56 PM
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
05-22-2002, 08:03 AM
Thanks, really good and saves a lot of clicks!

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

gmarik
06-09-2003, 12:22 PM
It shows Done! and does not redirects bakc to edit mode on 2.3 :pirate:

PixelFx
09-08-2003, 09:47 PM
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 ?