Welcome Guest, Not a member yet? Register   Sign In
How to redirect using $this-session-userdata(country_territory)
#8

(This post was last modified: 09-26-2019, 09:06 AM by christaliise.)

(09-24-2019, 08:17 AM)Wouter60 Wrote: Why not simply one controller that takes the country as a parameter? If you have a controller for each country, you'll probably have to write a lot of code over and over again. That's bad practice.
I would create a controller, e.g. "Adverts" and in that controller a function which accepts the country as parameter:

PHP Code:
public function show_adverts($country NULL)
{
  if (! $country) {
      show_error('You must include the country in the url!');
      die();
  }
  else {
      //get files form a subfolder for the given country and perform the actions you want.
  }


The url to call this function is:
Code:
https://yourwebsite.com/adverts/show_adverts/Afghanistan

If a user would include another country, all you need to do is handle that in the show_adverts function.

How do I allow the User to create an advert, then connect the advert with the country?

I have the country controller separated by function classifieds which provides for the User to upload an advert, but I don't know how to connect the advert and or the User to those classifieds.

Im thinking if I create a controller say named "Adverts" and have a series of functions named 1, 2, 3, 4, 5, and so on, to match the user_id, and create an advert template within each function. Would that be appropriate?

Is there some way to auto generate the function names either by user_id or user_name?
Reply


Messages In This Thread
RE: How to redirect using $this-session-userdata(country_territory) - by christaliise - 09-26-2019, 05:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB