Jump to content

davidmyers

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

davidmyers's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well the fact that you've already thought about it and taken it into consideration when doing things is a huge step forward. Keep up the good work.
  2. This looks really good. It'd be interesting to see what all has gone into the framework, but it works great from what I saw. I wish I was this far along when I was still in high school, haha. My only question would be if you've thought much about scalability. Just because you're making a social network to be better than facebook and if you're really serious about this you'll have to consider scaling at some point. Another reason to consider it is because the site may be running great now, but what about when it has 100,000 users or 1 million and so on. It can seem to far off to worry, but to prepare for scalability as far as databases goes completely changes the database design and functionality.
  3. Yeah, or include it in an external JS file. Also, make sure you call it inside of: It's just a jQuery thing to make sure it doesn't try to run before the page is finished loading.
  4. Ok, so I found a solution to my problem. Here is the code that I've ended up with: function SetValue() // Used to set values in current object { if(func_num_args() != 0) // Check for arguments { $Arguments = func_get_args(); // Get arguments $Variable = $Arguments[0]; // Set variable if(is_array($Variable)) // Check if first argument is an array of multiple variables to be set { $ObjVars = get_object_vars($this); // Grab associative array of Class variables foreach($Variable as $key => $value) // Loop through argument array { if(array_key_exists($key, $ObjVars)) // Check if argument array key is valid class variable { $this->$key = $value; // Set object variable with new value } else { // Send error return "error"; } } } else // Argument isn't an array so we're only setting one variable { $Value = $Arguments[1]; // Set variable $ObjVars = get_object_vars($this); // Grab associative array of Class variables $Variable = strtolower($Variable); // Convert argument of variable name to lowercase if(array_key_exists($Variable, $ObjVars)) // Check to see if argument is valid class variable { $ObjVars[$Variable] = $Value; // Update array with new variable value foreach($ObjVars as $key => $value) // Loop through array of variables { $this->$key = $value; // Set object variable with new value } } else // Not a valid class variable { // Send error return "error"; } } } else { // Send error return "error"; } } I know this topic was up for less than 24 hours, but it seems like every time I post a question I get almost no responses and no one ever gives me a solution. Either I'm not doing something right when I ask for help, or I guess there isn't much help to be had for more advanced issues? It's kind of frustrating because instead of getting the help I'm seeking I end up just getting answers that are irrelevant and solving the problem myself eventually. Sorry for the rant. In any event, here is the code for a completely dynamic Class Setter function that will either accept a variable and value or an associative array of variables and values. EDIT: I forgot two $'s in the code above.
  5. This is the kind of jQuery AJAX call you're going to want: var data = "&settingone=1&settingtwo=2"; $.ajax({ url: "index.php?option=dothis", type: "POST", data: data, success: function(string, variable){ if(variable === "success"){ alert(string); } else{ alert(string); } } }); It's a fairly straightforward piece of code. Data is anything you want to POST (or GET if you change type: to equal GET) to the Url. The function returns a string and a variable. The variable tells whether or not the AJAX call was successful or not and the string is whatever the Url returned. On it's own this will continuously make AJAX calls to that page.
  6. Ok, so I tried the .htaccess option first since it's the easiest but it didn't do anything. I'd try the first solution but I don't know where that file is. Ideally I'd like a solution that doesn't involve changing settings in PHP that have been deprecated for a reason. I realize that the way I initially tried to get this to work was the wrong way, but I can't think of any other way and that's really where I'd like help.
  7. I appreciate you trying to help, but I have no idea what you're talking about and that doesn't answer anything.
  8. That syntax is correct, but that doesn't work because get_object_vars is not written to return references. Your solution won't really work for me because it isn't dynamic in the way that I'm wanting. I'm trying to reference class/object variables without explicitly naming them anywhere except in the argument to the function if that makes sense. Also, the GetValue() function I posted works perfectly, it's the SetValue() version of the same code I'm trying to get working.
  9. I feel like I use to have a couple links to sites regarding this, but I can't find them. I do know of this one link though: http://www.developphp.com/view.php?tid=1037&t=Website_Design_Theme_Application_Tutorial_Using_PHP_Cookies_to_Change_CSS This guy uses cookies to store users theme choices and you can't customize them, but it's a good way to see step by step some of the things you'll need to get your own version working. Really though that's gonna be the easy part. Personally I'm a fan of jQuery and it would make the customization form a lot easier to process imo. I've been planning on building a feature similar to this, just with much customization. Mostly only letting users customize colors. But I'm thinking of possibly writing some tutorials in the future. If you'd be interested I could do this one first, just let me know.
  10. If you notice, I had found that out and said as much towards the end of my first post. Also, I'm not attempting to retrieve an object, I'm trying to get references to the variables of an object.
  11. I just realized that you said you were creating a form to add a new template to the site. To do this you would want to have them choose their options (which can be anything definable in css) and then use those to create a new stylesheet for that template using PHP. Then you would use the same kind of system that I already described to fetch the correct template for them whenever they visit a page. If you're setting it up where a site admin would do this but it would affect the entire site for every user, you would just check the "template" column value for the admin and apply that stylesheet every time the page is loaded. Honstly, creating a new template for the site in this way is valuable but will take a lot of work to write, especially if you're trying to make it really customizable. Also just saw your new post and I'm not sure what you would be using the textareas for. If you're including customization for page titles and such then you'll want to store that information in the database and call it like the stylesheet. In fact, if you have a lot of things you want to store about the templates, I'd make a table for template info and then have an entry for every user that specifies all of their options, like page header, css template name, etc.
  12. Ok, this is way different than what I initially thought you were wanting. If I understand this correctly, you want to have different site templates/layouts/themes that users can select to alter what the site looks like for them. First off you'll want to have every template/layout/theme work with the same base HTML, meaning that you have a bunch of div tags making up the page and what the site looks like is completely dependent upon the css applied to it. Then once you have all of your different template/layouts/themes created and working, have a place where the user can select the one they want. You can store their selection in a database either as a number or a name that references the particular template. So for instance a table column named "template" which holds the name of the template they chose. Then at the beginning of every page, just check the current users template variable and call the correct stylesheet accordingly. Hopefully this helps.
  13. I don't think I understand what it is you are trying to do. If you could explain in more detail or include code of what you've got that would help. If you're trying to make a form that is completely dynamic then it's pretty much the same principle of what I've shown you but will include accepting and handling lots of arguments, and will need lots of conditional statements.
  14. As a note, I've also attempted calling the function as a reference: $ObjVars = &get_object_vars($this); On the off chance that get_object_vars would return a reference, this was what I found to be the way to try it.
  15. What kind of errors are you getting? Because it is perfectly logical to put if else statements within loops.
×
×
  • 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.