Create a modular website, allowing the user to select their page layout. PHP and jQuery advice?
I am looking to build a website that allows the user to fully customise the content that they see. I will be building this using CodeIgniter or Zend Framework and also jQuery. What I need to know and gain some advice on is how is the best way to create the content on the fly,
When a user selects that they would like the blog sec开发者_StackOverflow中文版tion to be on their website, I need to gather the blog information on the fly and print out the appropriate div on screen.
What would be the best way to do this? Would I be best creating the Div in the DOM or just calling a view onto the page?
In my opinion loading views would be a much easier and maintainable approach.
Imagining trying to do that in javascript gives me a headache.
My recommendation is don't. Don't re-invent the wheel. Choose an already available system like Drupal or Joomla.
If you really need to re-implement this because of a constrain you cannot tell us, then all I can say is that using JQuery is a damn good idea.
One way is to create the dom objects on the fly using jQuery. This will work fine.
But another option would be to keep all your view logic in PHP and make a request to the server using jQuery, which will then return a snippet of html (a partial view). This would keep your code cleaner and your javascript files smaller and more manageable. Plus, whenever you make a change to your view, you won't have to do it in 2 places.
精彩评论