Welcome Guest, Not a member yet? Register   Sign In
where to generat links
#1

Hi,

I am newby to web development.

I am working on e-commerce website. 
I want to know where should I create product links.
In controller or in view.

I will appreciate it if you also explain the reason...

Thanks
Reply
#2

A link is an HTML construct and as such should be generated in a view file. But it depends what you mean by 'generating the links'. Suppose you are doing related products, the controller might call a product model, pass it the product id, and in the model you would get the related products from the DB, create an array of the product URL names and images (like 'my-fabulous-product' and 'my-fab-product.jpg' for instance), and return that array to the controller. The controller would then pass that array to your view file that outputs your related products section. In that view file, you would run through the URL names array, creating the listing for related products and generating the urls and image links according to however you have decided to file them using base_url for images and site_url for links.

Hope that helps.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB