Yii Framework Forum: How Get Full Url With Ancors? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How Get Full Url With Ancors? Rate Topic: -----

#1 User is offline   Helecta 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 02-March 12

Posted 22 October 2012 - 08:41 AM

How return current URL with anchors?
Example: I'm in page www.sitename#anchor
I want get full URL www.sitename#anchor, not www.sitename.
Yii::app()->request->getUrl() isn't suitable for this purpose
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,316
  • Joined: 04-March 10
  • Location:UK

Posted 22 October 2012 - 09:19 AM

The anchor part isn't sent to the server by the browser, so PHP can never see it.

More info here:
http://stackoverflow...tion-of-the-url

If you need it, you could use javascript to send it in a separate request.
0

#3 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 22 October 2012 - 09:21 AM

You can't get the anchor as it is not submitted to the server. If you need it you have to do an ajax request.
0

#4 User is offline   Luiz Celso 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 13-April 12

Posted 22 October 2012 - 09:27 AM

PHP can't get ancors.

Happy coding.
0

#5 User is offline   Helecta 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 02-March 12

Posted 22 October 2012 - 09:40 AM

Maybe i don't see simple solution.
I used extension rrgridview.
I use filters and choose one of record and go to it update.
I need to return back after i save all changes.
How can i do it, if i can't get (easily) anchors of url?
0

#6 User is offline   Jaggi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 05-September 11

Posted 22 October 2012 - 09:44 AM

to pass something in via the url you will need to use a GET or POST method. GET would be simplier if it isn't sensitive information, e.g. ?id=12&sitename=something
See my development site @ www.CodeTheInter.net (BETA)

Posted Image Posted Image

Quote

If you make it idiot proof, they'll build a better idiot
0

#7 User is offline   krowe 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 26
  • Joined: 27-September 12
  • Location:Peoria IL, USA

Posted 14 November 2012 - 03:24 PM

The first step is to get the grid view to generate the correct links. You'll want to add a new variable to each link (I use a variable named redir). So add the appropriate line of this to your grid view definition:

    ...
    'buttons'=>array(
        'update' => array(
            'url'=>'Yii::app()->createUrl(Yii::app()->controller->id."/update", array("id"=>$data->id, "redir"=>Yii::app()->controller->id."/admin"))',
        ),
        ...


Next, you'll want to modify your controller action:

...
if($model->save()) {
  if(isset($_GET['redir']) $this->redirect($_GET['redir']);
  else $this->redirect('whatever_you_want_to_make_the_default_action');
}


This is completely untested code, YMMV.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users