Welcome Guest, Not a member yet? Register   Sign In
Basic question: how to pass unique identifier with anchor()
#1

[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">
          <h2>Heading1</h2> // item1
           <p>text1 </p>
          <p><a class="btn" href="#">View details »</a></p>
       </div>
        <div class="span4">
          <h2>Heading2</h2> // item2
          <p>text2...</p>
          <p><a class="btn" href="#">View details »</a></p>
        </div>

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



#2

[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.
#3

[eluser]bill19[/eluser]
Thank You
#4

[eluser]InsiteFX[/eluser]
Code:
&lt;?php echo anchor('template_controller/'.$id, 'Learn More »', 'class="btn"'); ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB