Child pages
  • Best was to implement a Redirect using In-Portal tag
Skip to end of metadata
Go to start of metadata

Imported From: http://groups.google.com/group/in-portal-dev/browse_thread/thread/ea02c3610a0fd3c1#

Can someone 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.

Related Tasks

INP-530 - Getting issue details... STATUS

24 Comments

  1. 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. <dandre...@gmail.com>:

  2. 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 ::.. <p...@domicilis.biz>:

  3. 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>"/>

    On Thu, Mar 25, 2010 at 11:58 AM, Phil ..:: domicilis.biz ::.. <

  4. 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.

  5. 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?

  6. 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.b...@gmail.com>

  7. (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 ::.. <p...@domicilis.biz>

  8. 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.

    On Fri, Mar 26, 2010 at 4:22 AM, Phil ..:: domicilis.biz ::.. <

  9. 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 <dandre...@gmail.com>:

  10. 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.

    On Fri, Mar 26, 2010 at 9:59 AM, Phil ..:: domicilis.biz ::.. <

  11. 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 <dandre...@gmail.com>:

  12. 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.

    On Fri, Mar 26, 2010 at 10:31 AM, Phil ..:: domicilis.biz ::.. <

  13. 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 <dandre...@gmail.com>:

  14. 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.

    On Fri, Mar 26, 2010 at 12:47 PM, Phil ..:: domicilis.biz ::.. <

  15. 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 :)

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

  16. 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.

    On Fri, Mar 26, 2010 at 8:14 PM, Phil ..:: domicilis.biz ::.. <

  17. 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.b...@gmail.com>:

  18. 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.

    On Fri, Mar 26, 2010 at 10:31 PM, Phil ..:: domicilis.biz ::.. <

  19. 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.b...@gmail.com>

  20. 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.

    On Sat, Mar 27, 2010 at 10:35 AM, Phil ..:: domicilis.biz ::.. <

  21. 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.

  22. Excellent,

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

    DA.

  23. As you probably know the template name is considered external url, when it
    starts with "external:", so they will be processed automatically.

  24. Here is a task and first patch - please review:

    672: Create new m_Redirect tag

    INP-530 - Getting issue details... STATUS


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

    <

    INP-530 - Getting issue details... STATUS

    >DA.