jessadactyl Posted May 18, 2008 Share Posted May 18, 2008 Hey guys! I'm building a web application that requires a template system and I'm looking for a clean way to achieve this solution: When the "Template Manager" page is loaded, users will be prompted to either load an existing template or create a new one. Upon form submission their choice will be interpreted and appropriate functions will be executed. The problem is I figured I would use a URL parameter (template.php?t=139) to determine which existing template within the MySQL database should load. If no parameter is found, the load/create form will be displayed instead of the template editor. This approach works fine for simply loading an existing template since a select menu "onchange" event simply reloads the page adding the ?t={id} prefix. The creation of a new template however requires the use of form action="template.php". Obviously the template ID is unknown until the page reloads, validation is handled and my createTemplate($txt_tplName); method is executed. At this point however there is no clean solution to have the page reload with the template.php?t={new id returned from create template function} Any cleaner solutions would really be appreciated! (I'd prefer not using AJAX, simply to keep a feeling of consistency.) Link to comment https://forums.phpfreaks.com/topic/106143-looking-for-a-clean-approach-to-my-solution/ Share on other sites More sharing options...
GingerRobot Posted May 18, 2008 Share Posted May 18, 2008 Unless i've misunderstood, it sounds to me like you just need to re-organise your script a touch. The creating of a new id for a new template should occur before you check the URL for a given ID. You should then only check the URL if a new id has not been created. If it hasn't use the ID in the URL. If it has, use the created ID instead. Link to comment https://forums.phpfreaks.com/topic/106143-looking-for-a-clean-approach-to-my-solution/#findComment-544035 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.