Basic question: how to pass unique identifier with anchor() |
[eluser]bill19[/eluser]
Hi everyone, This a very basic concept, but I've never put together a website before so I've never thought about if before. I am working on the portfolio page of a website. On it there are 2 'summaries' of 2 separate items: Code: <div class="span4"> When I click on the button I want to go to a template page and dynamically fill in a more detailed discussion of each Item. But there has to be a way to uniquely identify item 1 and item 2 so I know which db record to use to populate the template. using the anchor function I can do: Code: ?php echo anchor('template_controller', 'Learn More »', 'class="btn"'); but how do I pass a unique identifier to the template controller? Thank you, Bill
[eluser]john_j[/eluser]
The syntax for anchor tag in CI is anchor(uri segments, text, attributes). What ever you pass to the controller can be extracted in the controller method using the syntax $this->uri->segment(n, 'somedefaultvalue'); So, your 'n' will be 3 (we are counting example.com as 0, next as 1 etc) if you had this format for the first argument of anchor(), http://example.com/class/function/ID.
[eluser]InsiteFX[/eluser]
Code: <?php echo anchor('template_controller/'.$id, 'Learn More »', 'class="btn"'); ?> |
Welcome Guest, Not a member yet? Register Sign In |