A few questions

edited August 2011 in News & Announcements
Hi everyone!
I have been with the codeigniter family for a few years and have stumbled upon FuelCMS for my latest project. I don't know why I didn't find it before. I think it's going to be a time saver for me!

I am in need of creating an affiliate section of our site in the sense of mySite.com/affiliateID. when you get to this section of our site, it looks like our site, but has our affiliates customized products to buy.

From what I can see, everytime we get a new affiliate, I can add a new page via the CMS and add the affiliateID as the page name and the URL would work correctly.

A few questions:
1. Will this slow the site down, say if we get 1000's of affiliates?
2. We want to track other affiliate information, via a module, can we auto create a page from the module when a new entry is made? Would this be a wise way to go?

Any thoughts and suggestions are welcome!

Thanks!
Roger

Comments

  • edited 10:27AM
    1. I don't see this being a performance issue but have not tested it to 1000 pages.
    2. I would recommend using either a model hook or a module hook (which is a new feature within the last couple weeks).

    If you use a model hook, I would recommend using something like the "on_after_save" hook on your "affiliates_model" which would automatically create a page record and any variables. To create the page and the page variables after saving in your affiliate module, you would need to do something like the following (haven't test it though):
    function on_after_save($values) { $this->load->model(FUEL_FOLDER, 'pages_model'); $this->load->model(FUEL_FOLDER, 'pagevariables_model'); $page = $this->pages_model->create(); $page->location = 'my_affiliate'; // URI location $page->layout = 'affiliate'; // the name of the layout located in the views/_layouts folder $page->cache = 'yes'; $page->published = 'yes'; $page_id = $page->save(); // now save page variables specific to the layout used for the page $pagevars = array(); // page title variable $pagevar1 = $this->pagevariables_model->create(); $pagevar1->page_id = $page_id; $pagevar1->name = 'page_title'; $pagevar1->value-> = 'My New Page Title'; $pagevar1->type = 'string'; $pagevar1->save(); $pagevar2 = $this->pagevariables_model->create(); $pagevar2->page_id = $page_id; $pagevar2->name = 'body'; $pagevar2->value-> = 'This is the body content of the page'; $pagevar2->type = 'string'; $pagevar2->save(); //.... and so on return $values; }
    Or, if you just like to create the page and have the user fill out the variables, you could redirect them to the page right after you do the $page->save(); like so:
    redirect('fuel/pages/edit/'.$page_id);
    More on model hooks:
    http://www.getfuelcms.com/user_guide/libraries/my_model (bottom of page)

    For a module hook I would use something like "after_save_affiliates" (assuming "affiliates" is the name of your module). Module hooks work like normal CI hooks:
    http://www.getfuelcms.com/user_guide/modules/hooks
Sign In or Register to comment.