Results 1 to 10 of 10

Thread: animated collapse 2.4 and mod_rewrite?

  1. #1
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default animated collapse 2.4 and mod_rewrite?

    1) Script Title:
    Animated collapse DIV v2.4

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...edcollapse.htm

    3) Describe problem:
    I wish to use the script along with SEO, as in mod_rewrite, so visitors/google can access my site through other URLS and have the DIV opened that the URL asks for (for example 'portfolio').
    Unfortunately when I access through mod_rewrite, the DIV doesn't expand as planned. When I access the full url, it does.

    In short:
    This does NOT work: http://www.mooimentha.nl/test/portfolio/
    And this does: http://www.mooimentha.nl/test/index....ddiv=portfolio

    The ReWrite is as follows:
    Code:
    RewriteRule ^portfolio/$ index.php?expanddiv=portfolio
    Any help would greatly be appreciated!

    [EDIT]
    I just found the following line n the animatedcollapse.js:
    Code:
    window.location.search.match(/expanddiv=([\w\-_,]+)/i) //search for expanddiv=divid or divid1,divid2,etc
    So it would seem I need an alternative piece/kind of script to pull the information, possibly combined with PHP? I can't seem to get my head around what to do right now...
    Last edited by mentha; 02-26-2010 at 09:23 PM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,140
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Try replacing the BODY of the function urlparamselect(), or:

    Code:
    	window.location.search.match(/expanddiv=([\w\-_,]+)/i) //search for expanddiv=divid or divid1,divid2,etc
    	return (RegExp.$1!="")? RegExp.$1.split(",") : []
    with the below instead:

    Code:
    	var segments=window.location.href.split('/')
    	var param=segments[segments.length-1] || segments[segments.length-2]
    	return param || []
    This should cause the script to look at the final URL segment and use that to match it against any collapsible DIV with the same value.
    Last edited by ddadmin; 02-27-2010 at 08:31 PM.
    DD Admin

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    mentha (02-27-2010)

  4. #3
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks! And I guess I could possibly combine this with an if/else if I should ever want to use the ?expanddiv=XXX as well?

  5. #4
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Unfortunately I'm getting an error:
    Code:
    missing ; before statement
    [Break on this error] return param : []
    Help? Please?


    EDIT:

    Well, fixed that issue all by myself *proud* to
    Code:
    var segments=window.location.href.split('/')
    	var param=segments[segments.length-1] || segments[segments.length-2]
    	return (param!="")? param : []
    But it's still not expanding. Any thoughts?
    Last edited by mentha; 02-27-2010 at 02:36 PM.

  6. #5
    Join Date
    Aug 2004
    Posts
    10,140
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    I've corrected my syntax error above. Taking another shot, try the below instead of the original function then:

    Code:
    urlparamselect:function(){
    	window.location.search.match(/expanddiv=([\w\-_,]+)/i) //search for expanddiv=divid or divid1,divid2,etc
    	if (RegExp.$1!="")
    		RegExp.$1.split(",") || []
    	else{
    		var segments=window.location.href.split('/')
    		var param=segments[segments.length-1] || segments[segments.length-2]
    		return param || []
    	}
    },
    DD Admin

  7. The Following User Says Thank You to ddadmin For This Useful Post:

    mentha (02-27-2010)

  8. #6
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    No script errors, but no automatic expanding either It's really odd, cuz if I add an alert in the script, I see that it does return the right data, but it's not getting picked up by the rest of the script, thus causing the lack of expanding.

    Thanks for thinking along anyway!

    I do think though, that once this is working properly, it might be a nice addition to the original script

    edit: typo

  9. #7
    Join Date
    Aug 2004
    Posts
    10,140
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm ok can you add an alert directly below the following line inside the .js file:

    Code:
    		var urlparamopenids=animatedcollapse.urlparamselect() //Get div ids that should be expanded based on the url (['div1','div2',etc])
    		alert(urlparamopenids)
    Then let me know? I'll test it out.
    DD Admin

  10. #8
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    The alert shows the right information (portfolio) when using http://www.mooimentha.nl/test/portfolio/

    But when using http://www.mooimentha.nl/test/index....ddiv=portfolio it says 'undefined'.

    (Based on the last version, with the if/else statement)

  11. #9
    Join Date
    Aug 2004
    Posts
    10,140
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Ah ok, try this version then:

    Code:
    urlparamselect:function(){
    	window.location.search.match(/expanddiv=([\w\-_,]+)/i) //search for expanddiv=divid or divid1,divid2,etc
    	if (RegExp.$1!="")
    		return RegExp.$1.split(",")
    	else{
    		var segments=window.location.href.split('/')
    		var param=segments[segments.length-1] || segments[segments.length-2]
    		return param || []
    	}
    },
    It should correct the non alert issue when the "expanddiv=xxx" option is used. Regardless though, you're still saying that even with the appropriate alert being shown, the DIV in question still does not expand for the mod_rewrite version of the URL?
    DD Admin

  12. #10
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Yes, now the "expanddiv=xxx" option works, including expanding div.
    But with the SEO version, no sliding DIV, though the alert clearly gives the right data.

    To see the difference:
    http://www.mooimentha.nl/test/portfolio/ <= not working
    and
    http://www.mooimentha.nl/test/?expanddiv=portfolio <= working

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •