![]() |
Can CI grab URL Hash (#page anchor) like uri_segment grabs segments ??? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Can CI grab URL Hash (#page anchor) like uri_segment grabs segments ??? (/showthread.php?tid=26879) |
Can CI grab URL Hash (#page anchor) like uri_segment grabs segments ??? - El Forum - 01-26-2010 [eluser]charlie spider[/eluser] for example: A form on a CMS page www.mysite.com/edit_page/about-us#seo posts data to a controller for processing, database update/insertion, etc, but then afterwards, needs to redirect back to the above URL. How do I use CI to grab the hash at the end of the above URL, as the hash does not appear within the uri_segment_array ? Thank you in advance for your time, effort and talent. Can CI grab URL Hash (#page anchor) like uri_segment grabs segments ??? - El Forum - 01-28-2010 [eluser]charlie spider[/eluser] wow i thought this was a simple one but it looks like i've stumped a few of you at least. any ideas? thanks Can CI grab URL Hash (#page anchor) like uri_segment grabs segments ??? - El Forum - 01-28-2010 [eluser]Cro_Crx[/eluser] You could do it with regex with a single line. For something more readable you can do this Code: /* Get the total number of segments */ The $last_hash value will be false if there isn't one. Although when checking you'll need to use === instead of just == Can CI grab URL Hash (#page anchor) like uri_segment grabs segments ??? - El Forum - 01-28-2010 [eluser]Cro_Crx[/eluser] Oh wait sorry. I misread. If the hash doesn't appear in the $last_segment you can use the URL held within the $_SERVER global. I'm not sure what index it is. Just use print_r() to find it. The code would look something like this: Code: /* Get the entire URL */ Just replace 'INDEX' with whatever the real index of the URL data is. Can CI grab URL Hash (#page anchor) like uri_segment grabs segments ??? - El Forum - 01-28-2010 [eluser]charlie spider[/eluser] Thanks for the reply Cro-Crx, a few things though: 1) There's no such thing as Code: $_SERVER['INDEX'] 2) Code: $_SERVER['HTTP_REFERER'] which is why... 3) i wanted to know if CodeIgniter has yet more magic up it's sleeves that can parse the hash from a URL i already tried what you had suggested anyways. I'm certain it can be done with javascript, but i'd like to stay server-side (and javscript feels like cheating anyways) Can CI grab URL Hash (#page anchor) like uri_segment grabs segments ??? - El Forum - 01-28-2010 [eluser]Cro_Crx[/eluser] Ya, I was saying that I wasn't sure of the index, so just replace INDEX with whatever it is in the $_SERVER array. Although as you said, it's not in any of the 3 that you've listed so you'll have to use JavaScript to read it. Reading up a bit about the topic. Apparently browsers don't send the anchor to the server, in that case it's not possible to recover. Can CI grab URL Hash (#page anchor) like uri_segment grabs segments ??? - El Forum - 01-28-2010 [eluser]charlie spider[/eluser] ergh... oh.. and thanks for the help |