Jump to content

ChemicalBliss

Members
  • Posts

    719
  • Joined

  • Last visited

    Never

Everything posted by ChemicalBliss

  1. How are you currently displaying the names in chat with flat file? are you using some sort of "active_users" file?
  2. The reasoning behind what you want to do seems detremental towards your projects consistency. when you program PHP you want to make clear boundaries, arguments must of a specific type, the more strict you are the easier it wil be to maintain the code when it grows. You should keep the error, since it looks like it would be a developer error rather than a user error, it should be a developer error message. For what you want to do though is a slightly more simple loop technique; $Form_Data = $this->info(); foreach($Form_Data As $key => $val){ // Each time this loops you get one of the form fields. So we can check each form field easily now. $field = $val; if($field['required'] !== true){ // This field says its value is not required. // You can do a check here like, if($field['name'] == "Full Name"){ // (i would use strtolower on both variables to not worry about Case) // This i think is what your looking for; $Form_Data[$key]['required'] = true; // Change the value in the original array. } } } // check the array. print_r($Form_Data); I would hard-code required fields into your script, you could use a mysql table to store which field names are required but for now i think your best to learn by using hard-coded values, you could still use an array, though. eg; $required_fields = array("name","address","email"); if(in_array($key,$required_fields)){ // ... do the change } Hope this helps.
  3. This may seem like a cheap-shot but have you tried google? I would say these forums are for people who are stuck with a specific problem/logic in their code. There are plenty of beginner tutorials with plentiful information on security and usability around the web regarding authentication. You will need to know a few basics and important vulnerabilities of PHP in order to make a production-level authentication system (one the public will use); Try some tutorials from here, phpfreaks: http://www.phpfreaks.com/tutorial/php-basic-database-handling http://www.phpfreaks.com/tutorial/php-security Then do a google for the actual authentication tutorial, there are hundreds, find one that looks right for your project. http://www.google.co.uk/search?q=php+authentication+tutorial hope this helps
  4. Depending on how you store user activity this should be relatively simple. For a chat script a user can "logout" or "timeout", a timeout is when the user has no activity for say 5 minutes. Everytime a user sends a message or refreshes the page or basically interacts with the chat script there should be a timestamp in that users field, or a new entry with the userid and timestamp in a table like "active_users". Lets go with the active users method; User interacts with the site -> Timestamp inserted or updated in the active_users table. Whenever the script refreshes or someone requests content, it should check the "active_users" table for any timestamps that are more than 5minutes old. This is very simple as its just; if $mysql_user_timestamp + (60*5) < time() then delete the entry from the active users table. Similarly if the user manually logs out the active_users entry is removed for that user. That way you know if there are no entries in the active_users table then there is no one online and therefor you can truncate the chat. Is this what you are trying to do?
  5. Try this code - i've added a debug catch that will collect info in a session array on each loop and force stop any loops at 10 runs, then print debug data. Look in the source code (View source) and copy/paste here. if($retval){ $_SESSION['DEBUG_COUNT'] = (isset($_SESSION['DEBUG_COUNT']))? ($_SESSION['DEBUG_COUNT'] + 1) : 1); $_SESSION['DEBUG_LOG'] = (!isset($_SESSION['DEBUG_LOG'])) array() : $_SESSION['DEBUG_LOG']; $_SESSION['DEBUG_LOG'][] = array( "current_path"=> realpath("./"), "next_path"=> realpath("../ClientArea/"), "login_result"=> $retval ); // Break any loops if($_SESSION['DEBUG_COUNT'] >= 10){ print_r( $_SESSION); unset($_SESSION['DEBUG_COUNT'],$_SESSION['DEBUG_LOG']); exit(); } header("Location: ../ClientArea/"); exit(); // Should put exit()s behind your header redirects }
  6. Try usnig the PHPSESSID query var and see if it works, if it does it's just not giving you the session cookie. Take a look at your browsers security and try setting a normal cookie.
  7. Here is how you merge your two tables: $row_array = array(); $row_names = array(); // Go through your result as usual while($row = mysql_fetch_array($result)){ /* This is the magic Merger, There is a new array called $row_array It starts empty but every time it goes through a row (loops), it will add the row to that array UNLESS it already exists in which case it will just add the string to it. */ // If this row exists in the new array.... if(isset($row_array[$row['id']])){ // Add the codes to the current string $row_array[$row['id']] .= ",".$row['codes']; }else{ // Otherwise add this row to the new array, and also its name in another array (with the same key/id) $row_array[$row['id']] = $row['codes]'; $row_names[$row['id']] = $row['name']; } } // Now we make the query we can give to mysql // Start with the first part (the next bit we can loop, as it can be the same thing over and over: (id,name,codes) (id,name,codes) .. etc $sql = "INSERT INTO `newtable` (id,name,codes) VALUES "; // We need an array of IDS since we are using for(), if we dont we would need to use its $i integer as the id but if you are missing an id it could change ID's of your users (dont want that). $row_ids_array = array_keys($row_array); // So, we loop for every item in the $row_array. for($i=0;$i<count($row_array);$i++){ // Get the current row ID $rowid = $row_ids_array[$i]; // Get the name using the retrieved row ID $rowname = $row_names[$rowid]; // Get the code same method $rowcodes = $row_array[$rowid]; // Make the SQL for this rows insert, and add it to the SQL string. $sql .= "('".$rowid."','".$rowname."','".$rowcodes."') "; } // VOILA! merged tables echo($sql); Understand this code - i have commented it so you should be able to follow it. Stuff like this can save you lots and i mean lots of time with old projects that you are updating. Among many, many other things. hope this helps
  8. You may need to learn a bit more about database design. Specifically, Relational Data You want a couple tables but you only use a single query. I would reccommend to google something like "Tutorial PHP MySQL JOIN", or if you enjoy reading something like "Relational Database Basics". Your tables would be like; 1. Your account Types (Holding where people get forwarded too for example) 2. Your Users (There would be a special field called something like "account_type_id", this would be the id number of an item in the above table. Your query would be something like: SELECT `table_accounttypes`.`redirect_url` FROM `table_users` INNER JOIN `table_accounttypes` ON `table_accounttypes`.`id`=`table_users`.`account_type_id` WHERE `table_users`.`username`='$someuser' AND `table_users`.`password`='$somepass' Hope this helps, good luck
  9. Can you give soem compelte examples of these multiple items, hwo would you like them to be merged? If you can show something like this: Table1 A B C D 435 John Edwards Empoyed 12/08/10 Table2 A B C D 435 Bill Jones Unemployed 10/01/11 Want to split them up so one of them has a new id. Something like that, show us what you want .
  10. Looks to me like you need a database design as doing flat-files (storing data in files) for this type of data can be much harder to learn than a few simple database calls. Take 5 minutes and google for a simple mysql tutorial, you will soon see that on a single page you could have all 3 fields for the date/header/text for the events, you can even easily handle several events within what we call a Table (or collection), You can sort the table, choose specific "items" in the table using Comparisons etc. To get you started, whilst reading the tutorials bear this in mind; TableName: my_events Field1: a number/integer (INT) Field2: characters (VARCHAR - maxlength 255 characters) Field3: timestamp (BIGINT) Field4: lots of characters (TEXT - you cannot do comparisons on this field type unless it is a "LIKE" comparison, you learn this later) Field1 Field 2 Field 3 Field4 id Snowboarding 1296255400 Going snowboarding Hope this helps and good luck
  11. I doubt you could "merge" rows that have different values whilst the query is running, or it would be overly complicated imo, Can i ask why you have rows with the same id? Ids need to be unique for a reason i think there is a problem with your table structure.
  12. Can i just say please wrap code in [ php ] tags, eg: [ php ]code...[/ php] Also, can i ask why you are checkign multiple tables? are they all exactly the same tables (same columns/fields)?
  13. Are you running windows 7? If you are there are more than likely Read-Only permissions on the session folder. Make sure there is not. Hope this helps
  14. Use an editor like notepad++ to edit PHP files, it will show new lines as they should be displayed regardless of wether it is a \n | \r or \r\n. There are different variations of the new line code because for some reason Mac/Windows and *nix think their newline method is the greatest (guess, but seems pointless to me). So Windows, using the native notepad wil only convert "\r\n" into a visible new line, since that is what it looks for. Similar to mac, its own variation of notepad may only convert \r into newlines, and *nix will convert \n. Notepad++ doesn't care wether its an \n or \r or both it will treat it the same, and you can even convert between the various formats with 2 clicks of the mouse. .. Also remember that the code that you echo to the browser is _not_ what you actually see, the browser "interprets" the "response" from the server which consists of headers and a body, the headers tell the browser things like what operating system, what encoding the page uses or even wether to cache the page to history or not or for how long etc, the body will contain the HTML, it is _always_ HTML (or sometimes XML for AJAX requests, but you dont _need_ to use XML) for webpages, wether designed for CSS or flash. Hope this helps clear things up.
  15. Just to let you know, I sorted it. I've had to do some Conveluded way of recursing the whole thing. A few patches here and there but it works at the moment without flaw (as far as i can tell). Basically I changed the code that made the initial array, the code that made it easier to work with, and managed to formulate a successfull collapse function. Like so; Original Array now comes in like this: Array ( [data] => Array ( [rkey] => %cdb_res_tpl_blk% [template] => default_tpl [content] => %custom_topmenu% <Br/>Table<Br/> %bigtablecustom1% ) [0] => Array ( [data] => Array ( [rkey] => %bigtablecustom1% [template] => bigtable_single [0] => Array ( [%title%] => Some Table Heading [%footer%] => Some Table Footer Message (author?) [%content%] => Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2% [%title_note%] => Some Time and Date ) ) [0] => Array ( [data] => Array ( [rkey] => %smalltablecustom1% [template] => smalltable_single [0] => Array ( [%title%] => Small Title [%content%] => Some Small Content or Note ) ) ) [1] => Array ( [data] => Array ( [rkey] => %smalltablecustom2% [template] => smalltable_single [0] => Array ( [%title%] => Small Title 2 [%content%] => Some Small Content or Note ) ) ) ) [1] => Array ( [data] => Array ( [rkey] => %custom_topmenu% [template] => custom_topmenu [0] => Array ( [%item1_name%] => Sub-Link 1 [%item1_link%] => # [%item2_name%] => Sub-Link 2 [%item2_link%] => # [%item3_name%] => Sub-Link 3 [%item3_link%] => # [%item4_name%] => Sub-Link 4 [%item4_link%] => # ) ) ) ) Then the code that makes it easier is now like so: // Recursive, goes through an array and converts any "data" into actual templates. (Puts the content into a template) private function parse_template_data_array($array){ // First let's count how many items are in the array that was passed to us $item_count = count($array); // This should never happen, each array should have at least a "data" array inside. if($item_count < 1){ // Template Parser Fatal Object Syntax Error exit("FATAL PARSER ERROR1"); // If there is only one item, we don't need to recurse (Tehre are no "child" elements) and so we skip the recursive section. }else if($item_count == 1){ // No items to parse, move on // So there are some child elements we must recurse through. }else{ // So this loops each "Child" element and passes that array to this function (recurse), Once it's finished it saves the array (result). for($i=0;$i<($item_count-1);$i++){ // -1 from the count, 1 to get rid of the data array. $array[$i] = $this->parse_template_data_array($array[$i]); } } // This part does the initial "template expansion", it finds the template needed for this item and saves it with the content to this item. // So we count how many data items we have $dcount = count($array['data']); // Count Data Items (minimum of 2 - Each data array must have "rkey" and "template") // If there isn't at least two items then someone made a booboo. if($dcount < 2){ // Template Parser Fatal Object Syntax Error exit("FATAL PARSER ERROR2"); // Otherwise lets sort this content out (We don't check if we only have the 2 minimum items since templates might not have Tags to replace). }else{ // Load Template file using the "template" item in the data array. $template = $this->get_file($array['data']['template']); // Count the amount of data items (content) to replace tags inside the loaded template (If tehre is no content sub-array then put to 0 to skip the below part). $dstrcount = (isset($array['data'][0]))? count($array['data'][0]) : 0; // No template content, maybe no tags, just give the template content back. if($dstrcount < 1){ // No items to parse // We have some content to replace. }else{ // We need the keys of the content sub-array so we can use (a neat feature of) the str_replace function. $akeys = array_keys($array['data'][0]); $template = str_replace($akeys ,$array['data'][0],$template); } // Save the result into this array item so we can pass the whole item back (This is also what happens when it recurses above) if($array['data']['template'] != "default_tpl"){ $array['data']['content'] = $template; } unset($array['data'][0]); } // Return the result array. return $array; } private function get_file($name){ return implode("",file(CDB_DOC_ROOT."cdb_includes/templates/".$name.".tpl")); } And finally the modified "easy" array: Array ( [data] => Array ( [rkey] => %cdb_res_tpl_blk% [template] => default_tpl [content] => %custom_topmenu% <Br/>Table<Br/> %bigtablecustom1% ) [0] => Array ( [data] => Array ( [rkey] => %bigtablecustom1% [template] => bigtable_single [content] => <div id="_box_gen"> <img id="_box_hdr_img" alt="sample topic" src="./images/icon_exclamation.png" width="25" height="25" /> <div id="_box_hdr"> Some Table Heading </div> <div id="_box_hdr_rht"> Some Time and Date </div> <div id="_box_top"> <div id="_box_cnt"> <center>Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2%</center> <div id="_box_lwr"> <div id="box_lwr_txt"> Some Table Footer Message (author?) </div> </div> </div> </div> </div> <br /> <br /> ) [0] => Array ( [data] => Array ( [rkey] => %smalltablecustom1% [template] => smalltable_single [content] => <table width="100" height="100" border="5"><tr><td>Small Title</td></tr><tr><td>Some Small Content or Note</td></tr></table> ) ) [1] => Array ( [data] => Array ( [rkey] => %smalltablecustom2% [template] => smalltable_single [content] => <table width="100" height="100" border="5"><tr><td>Small Title 2</td></tr><tr><td>Some Small Content or Note</td></tr></table> ) ) ) [1] => Array ( [data] => Array ( [rkey] => %custom_topmenu% [template] => custom_topmenu [content] => <a href="#" class="custom_menu_link">Sub-Link 1</a> - <a href="#" class="custom_menu_link">Sub-Link 2</a> - <a href="#" class="custom_menu_link">Sub-Link 3</a> - <a href="#" class="custom_menu_link">Sub-Link 4</a><br/> ) ) ) As you can probably see i've modified the template files. This is the result: <a href="#" class="custom_menu_link">Sub-Link 1</a> - <a href="#" class="custom_menu_link">Sub-Link 2</a> - <a href="#" class="custom_menu_link">Sub-Link 3</a> - <a href="#" class="custom_menu_link">Sub-Link 4</a><br/> <Br/>Table<Br/> <div id="_box_gen"> <img id="_box_hdr_img" alt="sample topic" src="./images/icon_exclamation.png" width="25" height="25" /> <div id="_box_hdr"> Some Table Heading </div> <div id="_box_hdr_rht"> Some Time and Date </div> <div id="_box_top"> <div id="_box_cnt"> <center>Some Content for the table with another rkey: <table width="100" height="100" border="5"><tr><td>Small Title</td></tr><tr><td>Some Small Content or Note</td></tr></table> --- <table width="100" height="100" border="5"><tr><td>Small Title 2</td></tr><tr><td>Some Small Content or Note</td></tr></table></center> <div id="_box_lwr"> <div id="box_lwr_txt"> Some Table Footer Message (author?) </div> </div> </div> </div> </div> <br /> <br /> And now the magic recursive function: private function build($array,$second_iteration=false){ $this->_tmp_sec_it = (!isset($this->_tmp_sec_it))? true : false; $_tmp_sec_it = $this->_tmp_sec_it; if($_tmp_sec_it == true){ $array['data']['content'] = $array[0]['data']['rkey']; $array['data']['rkey'] = $array[0]['data']['rkey']; } $acount = count($array); if($acount > 1){ for($i=0;$i<$acount-1;$i++){ $content = $this->build($array[$i], ($second_iteration == true)? false : (!isset($this->_tmp_sec_it))? true : false); $array['data']['content'] = str_replace($array[$i]['data']['rkey'],$content,$array['data']['content']); unset($array[$i]); } }else{ // No Array, skip } if($_tmp_sec_it == true){ return str_replace("%cdb_res_tpl_blk%",$array['data']['content'],$this->class_page->get_tpl_file()); } return $array['data']['content']; } So yeah, built in a few hard-coded values necessary to make it work but it works, and shouldn't hamper any usablity as long as i code the rest to hide it . Thanks for all who might of thought of a solution, I'm really not suprised I didnt get a response in time because even for me knowing what I was on about took me about 4 hours to figure this one part out! Now I am HAPPY --- If your still reading, note: $this->_tmp_sec_it is a class GLOBAL (((((( If ANYONE can make this function WITHOUT that global PLEASE tell me! I could even PAY!!! (Yes, I hate globals that much)
  16. Just for reference, MySQL also supports the >= (greater than or equal to) operator. eg, $result = mysql_query("SELECT `name` FROM accounts WHERE name = '".$_SESSION['auth_username']."' AND adminlevel>='1'") or die(mysql_error()); echo $result; echo "Num rows: ".mysql_num_rows($result); if(mysql_num_rows($result) <= 0) { echo 'RESTRICTED'; }else{ echo '<br /><br /><a href="home.php?admin">Admin Area</a>'; } But Maq's method is much more future-proof as you can check if the user has an adminlevel above a certain number several times without using mysql again, whereas above, if you had to check if the user had an access level above a different (higher) number then you would need another query.
  17. This could be more complicated than you think, depending on how complicated your code is at the moment. Basically what your thinking of is how most PHP programmers include "page content". Think of this structure: Home-> Includes-> school1-> Page1.php Page2.php school2-> Page1.php Page2.php school3-> Page1.php Page2.php Your "index.php" in your "Home" directory would control which website the user wants to see (using URL recognition or other methods). It would then proceed to include the page that was requested, but depending on which website the user wants it from it will grab it from where its needed, for example: User requests Page 1 using the url school1.alltheschools.com?page=1 PHP will recognize "school1" and "page=1". the include will look like: include("./includes/".$school_subdomain."/Page".$_GET['page'].".php"); This as i've explained is a security vulnerability since $_GET['page'] could be anything, and so if your "secure" pages were say, Page1secure.php, they could potentially gain access so jsut be aware of that. Hope this helps
  18. Then you want to change your query: "SELECT `name` FROM accounts WHERE name = '".$_SESSION['auth_username']."' AND adminlevel='1'"
  19. lol you didn't really produce any answers but just a shot in the dark: $result = mysql_query("SELECT adminlevel FROM accounts WHERE name = '".$_SESSION['auth_username']."'") or die(mysql_error()); echo $result; echo "Num rows: ".mysql_num_rows($result); if(mysql_num_rows($result) <= 0) { echo 'RESTRICTED'; }else{ echo '<br /><br /><a href="home.php?admin">Admin Area</a>'; }
  20. Added Note* I realize using a global variable this could be accomplished relatively easily but I HATE GLOBALS. Please do not use any "global" variables if/when you attempt this. I can write a method with a global variable so it wil not help . Thanks!
  21. Check my post nixie and tell us what it says, one problem at a time...
  22. Can you provide an example of the junk characters? (as output from your browser) compared to the REDHAT 8 output?
  23. When you "echo" a literal "integer" (a number that php knows is not a string), then you must turn it into a string to echo it properly. eg: $result = mysql_query("SELECT adminlevel FROM accounts WHERE name = '".$_SESSION['auth_username']."'") or die(mysql_error()); echo $result; echo "Num rows: ".mysql_num_rows($result); if(mysql_num_rows($result) == 1) { echo '<br /><br /><a href="home.php?admin">Admin Area</a>'; } Also i would change your If function: if(mysql_num_rows($result) !== false) { echo '<br /><br /><a href="home.php?admin">Admin Area</a>'; } Hope this helps
  24. Have you checked the source-code, can you give us an example of the "view Source" of your results?
  25. It's not usual I ask questions on here - I usually help rather than be helped but alas, this is really confusing ! Short Story (You can skip this to "Your Mission") Without going into unnecessary detail i'll try to explain what i'm trying to do; [*]Take an array (example provided...) Array( // These must be here, they are initially read by the template parser to get a starting point. "data"=>Array( "template"=>"main", // Template to start from (base template) "content"=>"%custom_topmenu% <Br/>Table<Br/> %bigtablecustom1%", // replace %content% tag,Shows 2 Examples, A Custom Menu, and Main Table with Smaller Tables inside ), // Below is numerically indexed arrays of content that will replace tags in the above "content" item 0=>Array( "data"=>Array( "rkey"=>"%bigtablecustom1%", // MUST have this item "template"=>"bigtable_single", // MUST have this item 0=>Array( "%title%"=>"Some Table Heading", "%footer%"=>"Some Table Footer Message (author?)", "%content%"=>"Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2%", "%title_note%"=>"Some Time and Date" ) ), 0=>Array( "data"=>Array( "rkey"=>"%smalltablecustom1%", "template"=>"smalltable_single", 0=>Array( "%title%"=>"Small Title", "%content%"=>"Some Small Content or Note" ) ) ), 1=>Array( "data"=>Array( "rkey"=>"%smalltablecustom2%", "template"=>"smalltable_single", 0=>Array( "%title%"=>"Small Title 2", "%content%"=>"Some Small Content or Note" ) ) ) ) 1=>Array( // The menu is dynamically created by the module using it's inherited protected methods. "data"=>Array( "rkey"=>"%custom_topmenu%", "template"=>"custom_topmenu", 0=>Array( "%item1_name%"=>"Sub-Link 1", "%item1_link%"=>"#", "%item2_name%"=>"Sub-Link 2", "%item2_link%"=>"#", "%item3_name%"=>"Sub-Link 3", "%item3_link%"=>"#", "%item4_name%"=>"Sub-Link 4", "%item4_link%"=>"#" ) ) ) ) [*]Turn this array into a single document, basically collpase all items with their children in the parent code. The Problem (You can skip this to "Your Mission") Now to make it easier and to (try) to prevent cross-tag contamination (so templates dont replace content that is supposed to be there from other template files...) I have wrote a recursion function that fills out all the content and removes the content sub-array from the data arrays (half the job). So now I have a multi-dimensional array that needs collapsing into a single document (variable), I am getting confused with how to go through this array (below - not above) so that all the template items are "inserted" inside their parent array items. The Function I made // Recursive, goes through an array and converts any "data" into actual templates. (Puts the content into a template) private function parse_template_data_array($array){ // First let's count how many items are in the array that was passed to us $item_count = count($array); // This should never happen, each array should have at least a "data" array inside. if($item_count < 1){ // Template Parser Fatal Object Syntax Error exit("FATAL PARSER ERROR1"); // If there is only one item, we don't need to recurse (There are no "child" elements) and so we skip the recursive section. }else if($item_count == 1){ // No items to parse, move on // So there are some child elements we must recurse through. }else{ // So this loops each "Child" element and passes that array to this function (recurse), Once it's finished it saves the array (result). for($i=0;$i<($item_count-1);$i++){ // -1 from the count, 1 to get rid of the data array. $array[$i] = $this->parse_template_data_array($array[$i]); } } // This part does the initial "template expansion", it finds the template needed for this item and saves it with the content to this item. // So we count how many data items we have $dcount = count($array['data']); // Count Data Items (minimum of 2 - Each data array must have "rkey" and "template") // If there isn't at least two items then someone made a booboo. if($dcount < 2){ // Template Parser Fatal Object Syntax Error exit("FATAL PARSER ERROR2"); // Otherwise let's sort this content out (We don't check if we only have the 2 minimum items since templates might not have Tags to replace). }else{ // Load Template file using the "template" item in the data array. $template = $this->get_file($array['data']['template']); // Count the amount of data items (content) to replace tags inside the loaded template (If there is no content sub-array then put to 0 to skip the below part). $dstrcount = (isset($array['data'][0]))? count($array['data'][0]) : 0; // No template content, maybe no tags, just give the template content back. if($dstrcount < 1){ // No items to parse // We have some content to replace. }else{ // We need the keys of the content sub-array so we can use (a neat feature of) the str_replace function. $akeys = array_keys($array['data'][0]); $template = str_replace($akeys ,$array['data'][0],$template); } // Save the result into this array item so we can pass the whole item back (This is also what happens when it recurses above) $array['data']['content'] = $template; } // Return the result array. return $array; } The Array returned by the above function Array ( [data] => Array ( [rkey] => %cdb_res_tpl_blk% [template] => main [content] => <html><head></head><body>%custom_topmenu%<br />%bigtablecustom1%</body></html> ) [0] => Array ( [data] => Array ( [rkey] => %bigtablecustom1% [template] => bigtable_single [content] => "Some Table Heading"=>"Some Table Heading", "Some Table Footer Message (author?)"=>"Some Table Footer Message (author?)", "Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2%"=>"Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2%", "Some Time and Date"=>"Some Time and Date" ) [0] => Array ( [data] => Array ( [rkey] => %smalltablecustom1% [template] => smalltable_single [content] => "Small Title"=>"Small Title", "Some Small Content or Note"=>"Some Small Content or Note" ) ) [1] => Array ( [data] => Array ( [rkey] => %smalltablecustom2% [template] => smalltable_single [content] => "Small Title 2"=>"Small Title", "Some Small Content or Note"=>"Some Small Content or Note" ) ) ) [1] => Array ( [data] => Array ( [rkey] => %custom_topmenu% [template] => custom_topmenu [content] => "Sub-Link 1"=>"Sub-Link 1", "#"=>"#", "Sub-Link 2"=>"Sub-Link 2", "#"=>"#", "Sub-Link 3"=>"Sub-Link 3", "#"=>"#", "Sub-Link 4"=>"Sub-Link 4", "#"=>"#" ) ) ) Your mission (Should you choose to accept ofc ), is to take the above array and turn it into a single html variable, with all the child elements inside their parent templates by replacing the tags in the array. All the data required is in the array, all that is needed is to "collapse" the array. Things to bear in mind: [*]%cdb_res_tpl_blk% - This is in the original template file, so the result of a successfull collapse will replace this tag with the result. Dont worry about this one [*][rkey] - This is the "Tag" to replace in the "parent" content. [*][template] - This is the template file. [*][content] - This is the content that needs to go inside the parent item. Expected Result <html><head></head><body>"Sub-Link 1"=>"Sub-Link 1", "#"=>"#", "Sub-Link 2"=>"Sub-Link 2", "#"=>"#", "Sub-Link 3"=>"Sub-Link 3", "#"=>"#", "Sub-Link 4"=>"Sub-Link 4", "#"=>"#"<br />"Some Table Heading"=>"Some Table Heading", "Some Table Footer Message (author?)"=>"Some Table Footer Message (author?)", "Some Content for the table with another rkey: "Small Title"=>"Small Title","Some Small Content or Note"=>"Some Small Content or Note" --- "Small Title 2"=>"Small Title","Some Small Content or Note"=>"Some Small Content or Note""=>"Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2%", "Some Time and Date"=>"Some Time and Date"</body></html> I will be working on this myself and if I find a solution I will post here. It is just that the way I code is I put my idea in my head, then try to code it in my head categorically, but when I think I find a solution it seems there is a bug, such as it will only collpase the main element, the bigtable, and the first small table, it wont do the other small table and not the menu either so basically it doesnt recurse items in the same array, only those underneath it. I'm so close but yet...so far... THANK YOU for ANY light you can shed on this situation it's been bugging me for a few days now (admittely have not coded since my first attempt - so tired.) My Code I won't provide the code I've done for it now since it just flat-out doesn't work, I've lost the code that I mentioned earlier that was bugged I modified and to be perfectly honest can't be bothered to reproduce it (it won't get me anywhere).
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.