We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

NEW - Redirect Plugin…

Development and Programming

Laisvunas's avatar
Laisvunas
879 posts
17 years ago
Laisvunas's avatar Laisvunas

Hi Andy,

Here is another piece of code which also should achieve what you want:

{if segment_1 == ""}
    {exp:weblog:entries weblog="home" dynamic="off" disable="member_data|trackbacks" limit="1"}
        //do some stuff
    {/exp:weblog:entries}
{if:else}
    <!--GET ALL CASESTUDIES BASED ON CURRENT PAGE-->
    {exp:weblog:entries weblog="casestudy" disable="member_data|trackbacks"}
        <!--IF THERES ONLY ONE RESULT...-->
        {if total_results == 1}
            <!--...REDIRECT TO THE ACTUAL CASESTUDY PAGE-->
            {exp:redirect_to location='/casestudy/{categories show_group="4"}{category_url_title}{/categories}/{url_title}' method="script"}
        {/if}
    {/exp:weblog:entries}
{/if}
       
Andy Harris's avatar
Andy Harris
958 posts
17 years ago
Andy Harris's avatar Andy Harris

Ahha, I see what I did. That works, thanks muchly….however the problem I have now is that I don’t want to use a javascript redirect if I can help it.

If I remove the method=”script” section, it redirects regardless of total_results. As this chunk of code is at the top of the page before (as far as I can tell) any header information is written, I would have thought I could do a PHP redirect. :(

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Right then. I have just uploaded the newest version of this to the first post and I have to make a public apology on the forums here to Laisvunas. He did a lot of work on this plugin adding in the new features and I went and added them into the plugin but forgot to upload it to the thread so for that I really do apologise.

Hopefully I have done it all correct and it should work as advertised. I will leave the original plugin in the first thread as well though just in case I have coded anything wrong. It’s just after 1 here and I am just a little bushed now!! 😉

Best wishes,

Mark

       
Laisvunas's avatar
Laisvunas
879 posts
17 years ago
Laisvunas's avatar Laisvunas

Hi Mark,

No need for any apologies. It was a pleasure to code some new features for your plugin.

Thanks for uploading new version.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

No problem and thanks again for all the help on this one. This community really is the best I have ever ever ever ever come across.

Hope you’re having a great week.

Best wishes,

Mark

       
Joobs's avatar
Joobs
362 posts
17 years ago
Joobs's avatar Joobs

I’m trying to use this to forward certain members to an alternative start page, but i’m having the problem mentioned here before that it forwards if the conditional is met or not. Any ideas how to fix this?

{if member_group=="1" OR member_group=="5" OR member_group=="6"}
{exp:redirect_to location="http://www.example.com/index.php/blog/"}
{/if}
       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hiya,

Try this instead with V1.2 :

{if member_group == "1" OR member_group == "5" OR member_group == "6"}
{exp:redirect_to location="http://www.yahoo.com" method="script"}
{if:else}
Not redirecting you this time!!
{/if}

That should hopefully do it for you?

Best wishes,

Mark

       
Joobs's avatar
Joobs
362 posts
17 years ago
Joobs's avatar Joobs

Thanks Mark, but unfortunatly I don’t really like using the script option.

I added the redirect to an embedded template and that seems to work.

I assume there isn’t a way to do it within the same template because of the advanced conditional problems mentioned in this thread?

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hiya,

Yep the problem arises as I think it all had something to do with not being able to re-direct using a PHP method after headers have already been sent so the only other way is to either use an embed as you have or use a Javascript method instead.

Best wishes,

Mark

       
baboonbrand's avatar
baboonbrand
14 posts
16 years ago
baboonbrand's avatar baboonbrand

Mark, Laisvunas,

Thanks guys, great plugin and really useful!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

No problem at all. Glad it’s come in of some more use somewhere 😉

Best wishes,

Mark

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi baboonbrand,

Since ExpressionEngine’s version 1.6.5 in which {redirect="template/template_group"} was made global there is no need to use Redirect To plugin to achieve redirection.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Whoops did I not mention that above.

Sorry baboonbrand meant to mention that although if people still want to use the plugin I don’t mind 😉

       
baboonbrand's avatar
baboonbrand
14 posts
16 years ago
baboonbrand's avatar baboonbrand
Hi baboonbrand, Since ExpressionEngine’s version 1.6.5 in which {redirect="template/template_group"} was made global there is no need to use Redirect To plugin to achieve redirection.

Thanks for heads up! Some of my clients need this functionality now, and the process for upgrading the core software is a bit lengthy, so this solution is perfect albeit temporary 😊

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Glad that it can still be of help somewhere. Always nice to hear 😉

       
First 2 3 4 5

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.