0

Might be an odd scenario, but i'm looking to use Solspace's facebook Login with a dynamic return by using segments in the url.

Currenttly fbc:login throws an error when I use any {segment} tags in the parameters.

Here's how they say to use the module: {exp:fbc:login permissions="email|publish_stream|read_stream" return_when_logged_in="site/home" return_when_logged_out="site/home" return_to_register="site/register" return_on_failure="site/fail" } {/exp:fbc:login}

Here's what i'd like to do

{exp:fbc:login permissions="email|publish_stream|read_stream" return_when_logged_in="{segment_2}/{segment_2}" return_when_logged_out="s{segment_2}/{segment_2}" return_to_register="site/register" return_on_failure="site/fail" } {/exp:fbc:login}

8
  • Alright. I got one answer. Its to have return_when_logged_in="/'{segment_2}'" and so on.. Perhaps a dirty solve, but it works. – Jordan Mar 20 '14 at 2:14
  • I would turn on Template Debugging and see how the values in these parameters are parsing in the {exp:fbc:login} tag. – Solspace Mar 20 '14 at 2:33
  • This is what i'm getting: return_when_logged_in="/'pricing'/''/''/'" return_for_passive_register="/'pricing'/''/''/'" It's not the best because we have all of the slashes and ' from the segments. It won't allow conditionals. Is this a major issue? – Jordan Mar 20 '14 at 2:36
  • Is this output after using your "hack", or when using return_when_logged_in="{segment_2}/{segment_2}"? – Solspace Mar 20 '14 at 2:48
  • sorry - should have clarified. Here's the actual tag: {exp:fbc:login permissions="email" return_when_logged_in="/'{segment_2}'/'{segment_3}'/'{segment_4}'" Then, depending what my segments are, the out put would be: return_when_logged_in="/'pricing'/''/''/'" My goal is to redirect users back to their task-flow. But they need to login/register before doing so. – Jordan Mar 20 '14 at 3:11
1

Using this kind of conditional in a parameter won't work well:

return_when_logged_in="{if segment_2}/'{segment_2}'{if:elseif segment_3}'{segment_2}'/'{segment_3}'/{if:elseif segment_4}'{segment_2}'/'{segment_3}/'{segment_4}'{if:else}/{/if}"

First, you shouldn't need those single quotes, as this could cause more issues than less.

Also with the above, you're using an advanced conditional within an {exp:...} tag's parameter. This gets parsed after the {exp:...} tag, which likely is giving you the error. Always use simple conditionals when working with parameters. In this case you could simply try:

return_when_logged_in="/{segment_2}/{segment_3}/{segment_4}"

However, your return URL may have a number of slashes at the end, eg. http://mysite.com/template_group/template//.

A better solution is the following, all using simple conditionals:

return_when_logged_in="{if segment_2}/{segment_2}{/if}{if segment_3}/{segment_3}{/if}{if segment_4}/{segment_4}{/if}"

Notice how all conditionals are simple conditionals. These will parse before the {exp:...} tag.

This is general EE advice, by the way, so can come in handy with 1st- and 3rd-party tags.

1
  • Great - Thanks for looking into that! Sorry it was a bit of pulling teeth for getting my result. – Jordan Mar 21 '14 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.