Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-30-2008, 03:32 AM
Junior Member
 
Join Date: Apr 2008
Posts: 5
Exclamation How to read parameters from URL in ZF?

Hi, some one please help me with this.

I build a web system with ZF, when user sign up, will need to activate via email that the system send out with parameter in the url such as "http://zxc.com/userId/34kjklnkj4k3jn" , userId is the parameter and "34kjklnkj4k3jn" is the value.

How I can read the parameter from the page? Consider my page have no class or function which $this->_request->getParam('userId); is not working.

Thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-30-2008, 02:21 PM
Elemental's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 122
Default

Unless you setup a custom route http://zxc.com/userId/34kjklnkj4k3jn will route to the user-idController.

You need to include the controller and action in your url, http://zxc.com/auth/register/userId/34kjklnkj4k3jn or something similar. Then userId will be in the params array and getParam will find it.
__________________
Zend Framework Resources: Zend Webinars | Reference Manual | API Docs | Books | FreeNode: #zftalk
Getting Started Tutorials: Getting started with ZF | Getting started with Zend Auth
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-22-2008, 01:20 AM
Junior Member
 
Join Date: Apr 2008
Posts: 5
Default

I need to read the parameter in index.php, though, index.php is not a controller. Big challenge to me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-22-2008, 09:08 AM
Junior Member
 
Join Date: Mar 2008
Posts: 26
Default

why do you need to read the parameter in index.php?? i can't see the point. maybe you are misunderstanding some things.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-22-2008, 10:08 AM
Junior Member
 
Join Date: Apr 2008
Posts: 28
Default

Code:
$this->_request->getParam('PARAM NAME HERE')
comes from url

Code:
http://localhost/<controller>/<action>/param/value/param2/value2/etc...
localhost can be anything really (wherever it's being hosted).
I don't see why there's a param in the index.phtml. Or why there should be one. But you can always concider linking to
Code:
http://localhost/<controller>/index
instead of
Code:
http://localhost/<controller>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-05-2008, 07:06 PM
Junior Member
 
Join Date: Jun 2008
Posts: 1
Default

Yes I want to know How I can get directly all the parameters. If I have url://mywebsite/<controller>/action/param1/value1/param2/value2/

Is it possible to get directly param1 and param2 values in one array (for example) ?

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-09-2008, 04:22 PM
Senior Member
 
Join Date: Jan 2008
Location: chicago
Posts: 101
Default

Yes, to access one array of all of the GET parameters, you can do

PHP Code:
$this->_request->getParams(); 
try
PHP Code:
<pre>
<?php print_r($this->_request->getParams()); ?>
</pre>
and see what you get!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 10-08-2008, 06:02 PM
Junior Member
 
Join Date: Jul 2008
Posts: 3
Default Same problem I think...

url = http://jaxiom/gratitudefrog/editreci.../recipes/id/50

Code is :
<pre>
<?php print_r($this->_request->getParams()); ?>
</pre>

Response is:

Fatal error: Call to a member function getParams() on a non-object in /var/www/html/jaxiom/application/views/scripts/gratitudefrog/editrecipe.phtml on line 2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 01:26 AM.