Best was to implement a Redirect using In-Portal tag

1 view
Skip to first unread message

Dmitry A.

unread,
Mar 24, 2010, 8:08:12 PM3/24/10
to In-Portal Development Team
Hi guys,

Can some one tell the best way to implement a redirect to a specific
template or external page using a tag.

My scenario is the following:

1. User goes to Customer Login page and does the Login.

2. I want to FORCE a redirect in case if logged in User ends up on the
same Customer Login page while already logged in. In practical live
want to redirect to the My Account or something.


Now, I've been checking all tag processors and didn't find any
existing tags...

Do you know any?


If we don't have this now, it's a good idea to add it to
kMainTagProcessor class, I believe.


Cheers.

DA.

Phil ..:: domicilis.biz ::..

unread,
Mar 25, 2010, 5:56:35 AM3/25/10
to in-por...@googlegroups.com
Hi Dmitry,

we actually have this tag :

<inp2:m_RequireLogin login_template="platform/login/register"/>

if you insert it in the top of "My account" page, then the page will
become a login page if user isn't logged in :-)

It's the kind of modification I've done before because it's really
more practical for users.

Phil.

2010/3/25 Dmitry A. <dand...@gmail.com>:

> To unsubscribe from this group, send email to in-portal-dev+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
>

Phil ..:: domicilis.biz ::..

unread,
Mar 25, 2010, 5:58:39 AM3/25/10
to in-por...@googlegroups.com
Sorry, I've forgotten to precise that I use "My account" page as the
login page, i.e. any link to login will link to this page.


2010/3/25 Phil ..:: domicilis.biz ::.. <ph...@domicilis.biz>:

Alexander Obuhovich

unread,
Mar 25, 2010, 10:12:42 AM3/25/10
to in-por...@googlegroups.com
Template name to shown next after login is made is stored in "next_template" hidden field on that login form. In your case you've managed to make so "next_template" is either empty or equals to that login page.

I propose to use such code to prevent that (already in "advanced" theme for quite a while):

<input type="hidden" name="next_template" value="<inp2:m_if check='m_Get' name='next_template'><inp2:m_Get name='next_template'/><inp2:m_else/>index</inp2:m_if>"/>
--
Best Regards,

http://www.in-portal.com
http://www.alex-time.com

Dmitry Andrejev

unread,
Mar 25, 2010, 11:13:12 AM3/25/10
to in-por...@googlegroups.com
Now what's going to happen if I come back to the same page while logged in - I'll see the login/registration page.

My idea was to have a tag that can redirect anything/anywhere - basically implementation of m_Redirect tag (similar to what we have in Application class)

DA.

Alexander Obuhovich

unread,
Mar 25, 2010, 3:56:35 PM3/25/10
to in-por...@googlegroups.com
Why to have RequireLogin and Redirect that both redirect. It's bad practice to perform redirects from templates. Maybe you should change what template is user visiting and on what template RequireLogin tag is placed as Phil proposed.

Is this an "advanced" theme or you are developing something new?

Phil ..:: domicilis.biz ::..

unread,
Mar 26, 2010, 5:21:16 AM3/26/10
to in-por...@googlegroups.com
Alex, Dmitry,

I'm aware of the redirect feature "next_template", but I've proposed this other solution for many reasons:

   - the login process become an optionnal page when trying to reach account, while if we use the next_template method user will have a link to a page, which redirect him to another page : slower display, resources consumming

   - using a direct link to My Account, we don't have to remember if all My Account links are a form, it works anytime, anywhere, even from a link inside a mail ;-)

   - the less step a customer have, the better is it

   - an user never login just for pleasure of login, it's because :
a. he wants to gain access to his account
b. he wants his address to be filled automatically when ordering (this is done naturally in the order process if "always connect before ordering" is checked in admin)
c. he wants to perform any kind of action where login is required (posting a news, a review)

Because of all these reasons, I prefer to ask to login on the requested page, but the login page itself isn't so interesting :-)
I don't see any changes to make to actual code... your opinion?

Phil.


2010/3/25 Alexander Obuhovich <aik....@gmail.com>

Phil ..:: domicilis.biz ::..

unread,
Mar 26, 2010, 5:22:16 AM3/26/10
to in-por...@googlegroups.com
(and of course, this is thanks to next_template we can come back to the previous page, it works perfectly in this function)

2010/3/26 Phil ..:: domicilis.biz ::.. <ph...@domicilis.biz>

Dmitry Andrejev

unread,
Mar 26, 2010, 10:40:53 AM3/26/10
to in-por...@googlegroups.com
Phil,

Please describe how you would solve the following task:

Forget the login for a moment, let's apply this to a more general task.

You need to send user to some specific template B (or external URL) based on some other conditions whenever he visited template A (page)?


Thanks.

DA.

Phil ..:: domicilis.biz ::..

unread,
Mar 26, 2010, 10:59:20 AM3/26/10
to in-por...@googlegroups.com
Dmitry,

can you describe me which type of condition do you talk about:

- the link would work only if this condition is met?

- the link would work anytime and would include an information,
such as logged in or not?

I'd need a clear example at best ^-^

Phil.

2010/3/26 Dmitry Andrejev <dand...@gmail.com>:

Dmitry Andrejev

unread,
Mar 26, 2010, 11:13:02 AM3/26/10
to in-por...@googlegroups.com
I am on Registration template or any other and checking if user is already logged in I want to send him to My Account page.

I am not the fan of putting IF around the major forms or parts of the template. 


DA.

Phil ..:: domicilis.biz ::..

unread,
Mar 26, 2010, 11:31:36 AM3/26/10
to in-por...@googlegroups.com
well, I don't understand why you dont like the inp2:m_RequireLogin tag
? It's not an if command...

2010/3/26 Dmitry Andrejev <dand...@gmail.com>:

Dmitry Andrejev

unread,
Mar 26, 2010, 11:38:27 AM3/26/10
to in-por...@googlegroups.com
Phil,

Again it's NOT just about user being logged in or non-logged in - there is many more cases I can use this tag, but you asked for very specific scenario, here it comes:

1. user is already logged in

2. user goes to Registration page and NORMALLY would see the Form, but I want him to end up on My Account page (or similar) since no point of seeing Registration when logged in correct?

It's just 1 simple example of usage, but there are many other custom cases when this is useful to have.

Let me know if you want more explanation.

DA.

Phil ..:: domicilis.biz ::..

unread,
Mar 26, 2010, 1:47:19 PM3/26/10
to in-por...@googlegroups.com
Dmitry,

1. user is already logged in

- where can user clic on the register link, which appears only
under login box (on advanced theme)?

- if you are using a custom theme, why providing a link to register
in another place than inside the login box or login page?

2. user goes to Registration page and NORMALLY would see the Form,
but I want him to end up on My Account page (or similar) since no
point of seeing Registration when logged in correct?

- as I said before, if the register page doesn't have any direct
link to it (and I called only with the special tag for this purpose),
user cannot see the form otherwise than opening register page in
another browser's tab, and log on the first tab... but why doing so?

- why not using the tag <inp2:m_if check="m_LoggedIn"> in the
register page? if you place an include for my account content into the
ELSE part of the tag, it'd do the same. ok It's an IF, but all
in-portal is made of IF tags :)


I totally understand your question, but what would be the difference
between <inp2:m_if check="m_LoggedIn"> tag and the new one you'd like?
Also, pages which automatically redirect is worst than IF, as it rely
on a perfect working redirection, why this redirection would work more
safely than the IF tag? ^-^

Phil.

2010/3/26 Dmitry Andrejev <dand...@gmail.com>:
> Phil,

> Again it's NOT just about user being logged in or non-logged in - there is
> many more cases I can use this tag, but you asked for very specific
> scenario, here it comes:
> 1. user is already logged in
> 2. user goes to Registration page and NORMALLY would see the Form, but I

Dmitry Andrejev

unread,
Mar 26, 2010, 2:00:45 PM3/26/10
to in-por...@googlegroups.com
Phil,

As I said you are looking at 1 example you are using - Logged in or Not Logged in.

I personally came across 3 different themes were I had to Custom extend MainTagProcessor just to add this Redirect tag, and now when I am finishing new theme of In-Commerce store - I came across the same issue.

In other words, most of your notes are specific to the Advanced theme, while I am trying to explain that <inp2:m_Redirect template="" pass=""/> will actually allow you to perform redirect to ANY local page or item, or external.

I am just surprised you have have never came across this...


DA.

Phil ..:: domicilis.biz ::..

unread,
Mar 26, 2010, 2:14:38 PM3/26/10
to in-por...@googlegroups.com
Well, may this tag could be usefull, and as I don't know the case
you've solved, my opinion isn't very interesting on a problem I don't
know exactly...

And yes, I never came accros this, I'd be pleased to know ins and outs
to understand better :)

Alexander Obuhovich

unread,
Mar 26, 2010, 3:24:20 PM3/26/10
to in-por...@googlegroups.com
About registration page link Phil. If you doesn't display link to a page on the site, then it doesn't mean, that user can't access it by typing direct url in browser or by using favorites. Keep that in mind.

Hiding link is not enough, all related functionality should also be blocked from direct access.

Phil ..:: domicilis.biz ::..

unread,
Mar 26, 2010, 4:31:30 PM3/26/10
to in-por...@googlegroups.com
yes, but once again, as said before:
user cannot see the form if logged otherwise than opening "register"

page in another browser's tab, and log on the first tab... but why
doing so? what is the interest for the user?

2010/3/26 Alexander Obuhovich <aik....@gmail.com>:

Alexander Obuhovich

unread,
Mar 27, 2010, 5:55:41 AM3/27/10
to in-por...@googlegroups.com
Don't for forget about hackers. They usually do what you never suppose anyone will to get what they want. We must ensure, that our code and themes is most secure.

Phil ..:: domicilis.biz ::..

unread,
Mar 27, 2010, 11:35:35 AM3/27/10
to in-por...@googlegroups.com
you are right, I'm myself thinking about that too, I don't see what could happen, but I'm not in the code, and you surely knows better than me if there's security flaw in the code. thank you for your reply.

2010/3/27 Alexander Obuhovich <aik....@gmail.com>

Dmitry Andrejev

unread,
Mar 28, 2010, 11:38:16 AM3/28/10
to in-por...@googlegroups.com
Alright guys, I am glad we came so some understanding why we need the tag.

Alex, before doing it - if you don't mind let' try to cover all possible Scenarios where we can use it and Parameters we can pass to it.



1. Internal Redirects.

Parameters:
a. t, template - for template
b. pass - to pass prefixes
c. category_id - some way to pass SectionId if I want to direct user to pages which is a section in the structure and need to build correct URL?
d. any extra Vars that will be pass can be attached too (as m_Link I guess)?

2. External Redirects.

a. t, template - with "external:" prefix and then actual "http://www.google.com" page


What you think?

DA.

Alexander Obuhovich

unread,
Mar 28, 2010, 12:29:25 PM3/28/10
to in-por...@googlegroups.com
I think, that we will process same parameters as m_Link tag does in same format, because Redirect will call m_Link inside, so no need to fancy named parameters like "category_id", since m_cat_id already works.

Dmitry Andrejev

unread,
Mar 28, 2010, 12:34:47 PM3/28/10
to in-por...@googlegroups.com
Excellent,

What about processing external URL we already have all that, and that or will be doing within our tag?

DA.

Alexander Obuhovich

unread,
Mar 28, 2010, 1:45:00 PM3/28/10
to in-por...@googlegroups.com
As you probably know the template name is considered external url, when it starts with "external:", so they will be processed automatically.

Dmitry Andrejev

unread,
Mar 28, 2010, 8:06:24 PM3/28/10
to in-por...@googlegroups.com
Here is a task and first patch - please review:

672: Create new m_Redirect tag



PS. Not sure if we need to add JS redirect there AND check for recursion with redirect. 


DA.
Redirect_tag-Dmitry-20100328-v1.patch

Alexander Obuhovich

unread,
Mar 29, 2010, 2:44:48 AM3/29/10
to in-por...@googlegroups.com
Not good actually. Why to replicate part of kApplication::Redirect method? Can't we simply call it with all tag parameters given to it?

Dmitry Andrejev

unread,
Mar 29, 2010, 4:43:42 PM3/29/10
to in-por...@googlegroups.com
Yes, I thought of it, but wasn't sure if it's a better idea to have separate implementation code as we have in m_Link and m_T methods...

Basically right now I process everything straight forward to m_Link (goes through T and HREF) with setting/unsettling what needs to be done to build standard URL and then processing the Redirect.

How would you combine / substitute this with Application Redirect method when it does HREF on it self in the middle without repeating the code from m_Link and T...?


DA.

Alexander Obuhovich

unread,
Mar 30, 2010, 3:45:15 AM3/30/10
to in-por...@googlegroups.com
I've unified m_Link and m_T tags in proposed patch and centrally moved "admin"/"editing_mode" parameters processing to "HREF" method itself.

So after applying this patch you can copy body of "m_T" tag into "m_Redirect" tag and just call kApplication::Redirect method at the bottom instead of kApplication::HREF.
unification_of_mLink_and_mT_tags.patch

Dmitry Andrejev

unread,
Mar 30, 2010, 8:03:03 AM3/30/10
to in-por...@googlegroups.com

Dmitry Andrejev

unread,
Mar 30, 2010, 8:04:41 AM3/30/10
to in-por...@googlegroups.com
Thanks Alex, will review and update my code

DA

Alexander Obuhovich

unread,
Mar 30, 2010, 8:06:04 AM3/30/10
to in-por...@googlegroups.com
I've attached patch from my previous post to http://tracker.in-portal.org/view.php?id=626 task, since it is better fix to it.

To unsubscribe from this group, send email to in-portal-dev+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

Dmitry A.

unread,
Mar 31, 2010, 2:06:58 AM3/31/10
to In-Portal Development Team
Thanks Alex - will review and update my work!

DA

On Mar 30, 7:06 am, Alexander Obuhovich <aik.b...@gmail.com> wrote:
> I've attached patch from my previous post tohttp://tracker.in-portal.org/view.php?id=626task, since it is better fix to
> it.


>
> On Tue, Mar 30, 2010 at 3:04 PM, Dmitry Andrejev <dandre...@gmail.com>wrote:
>
>
>
>
>
> > Thanks Alex, will review and update my code
>
> > DA
>

> > On Tuesday, March 30, 2010, Alexander Obuhovich <aik.b...@gmail.com>


> > wrote:
> > > I've unified m_Link and m_T tags in proposed patch and centrally moved
> > "admin"/"editing_mode" parameters processing to "HREF" method itself.
>
> > > So after applying this patch you can copy body of "m_T" tag into
> > "m_Redirect" tag and just call kApplication::Redirect method at the bottom
> > instead of kApplication::HREF.
>

> > > On Mon, Mar 29, 2010 at 11:43 PM, Dmitry Andrejev <dandre...@gmail.com>

Reply all
Reply to author
Forward
0 new messages