open link redirect to page with id working on doctrine
I didn't know how to ask professional so if topic is wrong, please correct it.
My problem is quite complicated. I was training on symfony webpage how to generate form and then send this data to another page.
But now i would like do something different. I would like create page xyzSuccess.php. Then generate 29 links on this page. Each links would ha开发者_运维技巧ve its own number. Each link would redirect to the same page. For example numberSuccess.php. After that, this site would give me data of the number which i clicked.
I will show the example :)
I dont know how to do this, i don't want use any database eq. *sql
So far i created only page xyz.php which use php for loop. I see that action.class.php would work with it if i would use submit button, but i really dont have any idea how make this working with links. And... that problem with storing data :( maybe create file in lib/form ?
corrected the link to page (deleted success which used only in templates), guy under is right :)
First of all, you're talking about URL's like /web/numberSuccess
... That probably means you've misconfigured the root. Also see this question, asked today.
Then it's common to give your actions names like number
, and then in you're actions file you have the executeNumber
action, which then renders the numberSuccess
template. So you shouldn't include the Success
in the action name/URL.
Then, your question: What I would do, if you don't want to use a database:
- Create a file
links.txt
in your/data
directory, and on every line create an url, followed by a space and then the title of your link. - In your list action open the this file using
file_get_contents()
, explode it on the newline-character, and assign this array to the view. - In your view loop through the array, use the array index as your
number
, and explode each item on the first space, so you can display the title. - In the view action your open and explode the links file again, and now you can pointer directly to the index, explode again and you have the URL.
精彩评论