Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by maxxd

  1. Right. As I said, target was just a thing - assign the value of that to a variable you can use. If you're passing in a string reference to the DOM object (for instance: swapContent('http://myURL.com', array('testing','more'), 'myDivID'); ), this should work for you: var tgt = '#' + target; $(tgt).html('<p>Woot</p>'); If you're passing in the DOM object itself (as such: swapContent('http://myURL.com', array('testing','more'), $('#myDivID')); ), just use it directly: tgt.html('<p>Woot!</p>');
  2. Is $ds defined in the function (or function sheet) you're altering? Check the code on the page you're using as an example - it's probably (I'm assuming you're using WordPress) a global, and you should be able to use it by adding global $ds; at the top of the function. However, it's difficult to tell without looking at the code.
  3. Yeah, I understand that JS won't save the files, just thought it could initiate the request to the user to save the file. Thanks for the link to the plugin - I'll check that out!
  4. Thanks guys (or gals, not sure). The thing is, I've seen this method work for a dynamically created .zip file before, and can't quite figure out why it's not doing anything for a CSV. I'll give a shot to the redirect method, which hopefully will work in WP. And thanks much for the heads-up on the output stream. I'm not terribly excited about the prospects of writing and deleting a file on the server every time my client wants to export the data, so that'll put my mind at ease a bit!
  5. Try setting the $keys array index to the post ID? I'm honestly not entirely sure what you're hoping to see as the output. Right now, the $keys array is going to be a numerically-indexed array of page slugs, so the select options are probably going to look a lot like this: <select value='1'>page_slug_1</select> <select value='2'>page_slug_47</select> <select value='3'>page_slug_15</select> etc.. If you want to associate the page with it's slug, create the array like this: foreach($pages as $page){ $keys[$page->ID] = $page->post_title; } then use $keys as the value of 'options'. I'm not familiar with the Quemalabs theme, so I don't know exactly how you're creating the select box, but from what you've said I think this'll work for you.
  6. Try removing the second array_fill_keys() and adjusting to 'options' => $objects. I don't have time to test, but it looks to me like you're putting the array $objects into each index of $options.
  7. Hey y'all. I've dug around on SO and other sites, and pretty much everything I'm finding is making me think that what I'm doing here should be working. Problem being, it's not. First, a little background. I'm trying to create a CSV export of a WordPress back-end report that I've built and have had working for a bit now. I'm using AJAX to gather the data for both the display and the export. So, the user selects a date range, clicks 'Go', and the system uses AJAX to populate the report data into the table as expected. At this point, the user can click the 'Export' button, and - theoretically - once again the page uses AJAX to gather the data and display a 'Save as...' window with the newly generated report. My PHP code: public function exportReportData(){ $data = $this->gatherReportData(false); $tmp = tempnam(sys_get_temp_dir(), 'your_csv_dl'); if($tmp === false || !file_exists($tmp)){ print(json_encode(array('success',false))); exit; } $fileName = 'report_'.(new \DateTime())->format('Ydmhis').'.csv'; $handle = fopen($tmp,'w'); foreach($data as $row){ fputcsv($handle,$row); } fclose($handle); header('Content-Description: File Transfer'); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename='.$fileName); header('Expires: 0'); header('Cache-Control: no-cache must-revalidate'); header('Pragma: public'); header('Content-Length: '.filesize($tmp)); readfile($tmp); unlink($tmp); exit; } The system outputs the expected data - I can view it in my console. However, it doesn't pop up the expected 'Save as...' dialog, and I have no idea why. I've tried Content-Type: application/octet-stream, text/csv, application/csv, and a couple others that I can't remember right now. So, a couple questions - first off, the obvious. Does anyone see anything in the code above that's causing it to not work as expected? Did I leave something out, use the wrong value for a header, name something incorrectly, anything at all? Secondly, if I'm creating the file in the server temp directory, is it necessary to unlink() it at the end of the script, or will garbage collection take care of it on it's own? Any and all help is much appreciated, and thanks for taking the time to take a look.
  8. Why not define the system path in the constant? Instead of 'http://example.com/site/2/' use '/public_html/your_account/site/2' - this way you can put your included files above the web root for security if you want, plus you still only have to change the constant value once across the site.
  9. maxxd

    Browser Support

    If you're looking for CSS compatibility information, check CanIUse.com. As far as Safari support goes, modern versions on the Mac handle vh and vw just fine. If someone's using it in a Windows environment, well... support was dropped for that quite some time ago.
  10. It's possible the error is referring to the attempt to read $_REQUEST['sort'] - try print("<pre>".print_r($_REQUEST, true)."</pre>"); before line 15. Also - and this is more a personal preference, so take it with a grain of salt and all, but don't use $_REQUEST. Variables in the $_REQUEST superglobal can come from $_GET, $_POST, $_SESSION, or $_COOKIE. Know what data you're looking for and where to find it. If you submit your form using post, check $_POST; if you submit using get, check $_GET.
  11. Set up the frequency as DateInterval() objects, then feed them to DateTime::add() as necessary. DateTime::add() - http://php.net/manual/en/datetime.add.php DateInterval() - http://php.net/manual/en/class.dateinterval.php
  12. The $('#target').innerHTML was kind of a stub. I should've mentioned the code wasn't tested - sorry. My point was to get you moving in the right direction, not give you a cut and paste solution. It looks like you're passing target as a DOM reference, so the way you've got it set up now should be working. What's the output of the processing script in the console?
  13. You could check the contents of $('#res3') and only run the AJAX call if it's empty. Or, set a variable (loaded = true, for instance) in the .success() function of the AJAX call and check that before you attempt to load the data again.
  14. You shouldn't have to append the data directly to the url - using the 'get' method will handle that for you, as well as JSON encoding the data. However, you do have to give the data to the ajax call. $.ajax({ type:'get', url:href, beforeSend:function(){ $('#target').html("<p>Doing something - please wait.</p>"); }, data:url_data, }).done(function(ajaxObject){ var resp = JSON.parse(ajaxObject); if(resp.success == true){ $('#target').html("<p>Woot!</p>"); }else{ $('#target').html('<p>Processing error - system returned false!</p>'); } }).error(function(){ $('#target').html('<p>System error - not processing related!</p>'); }); Note that there' are both a done() and error() handler attached to this. sucess() will always fire as long as the call itself goes through - there's no guarantee that the processing was successful.
  15. Try this in your CSS: #my-button{ position: absolute; top: 50%; -ms-transform: translateY(-50%); -webkit-transform: translateY(-50%); transform: translateY(-50%); } Obviously change the #my-button identifier to whatever ID you're using for the button, and make sure the surrounding container has a position: value of either 'absolute' or 'relative'.
  16. Contact form 7 allows telephone fields with [tel ... ] - I think CF7 will validate it as a phone number on submission, but don't quote me on that. If it doesn't, you'll have to use a JS regex - quick example here.
  17. That would also explain why you were getting the duplicate entry error. Glad you got it fixed.
  18. As long as you want unique usernames, the system is actually functioning as it should. While you're testing, either make up a new username for each manual test, or delete the inserted row after each manual test. And yes, header('location:login.php?msg=Registered_successfully'); is what you want (note that I removed the space in the value of msg).
  19. Sounds like you've got a unique constraint (or index) on the username column of your table. What's redirect_to()? That's not a php function.
  20. At the top of your script, you're checking the value of $error before you've created the variable. use isset() instead. And further down in the script you switch from $_FILES['photo'] to $_FILES['uploadedfile'], which apparently doesn't exist.
  21. There are several PDF libraries for php, most of which handle everything you're wanting to do. I've used mPDF in the past and it does allow watermarking, font embedding, etc. - I'm not sure it's the most up-to-date library out there, but I know it worked well when I used it about a year or so ago.
  22. They may be folders, but in this case you're dealing with namespaces, not folder structure. Assuming everything in Cake is using an autoloader, I would expect to find the namespaces correspond with the directory structure, but it certainly doesn't have to.
  23. You'll be able to call anything protected or public in Init() from within Router(). If you don't need to do anything different with a method in the Router() class, don't define it in the Router() class and the call will bubble up to Init() automatically. For instance: class ParentClass{ /** * Runs because the constructor is called on the child class and not intercepted. */ public function __construct(){ print("<p>This is ParentClass() calling!</p>"); } /** * This is public and can be called from anywhere */ public function doStuff(){ print("<p>Now ParentClass() is doing stuff!</p>"); } /** * This is protected, so can only be called from the child class. However, * we're doing more with this method by adding another line of output after * calling this method from the child class. */ protected function polymorphismAtWork(){ print("<p>ParentClass() says 'hi!'</p>"); } /** * Again, this is protected and can only be called from within a child class. */ protected function protectedFunction(){ print("<p>This method is protected!</p>"); } /** * Not even a child class can call this method. */ private function privateFunction(){ print("<p>Nope. No access, thanks</p>"); } } class ChildClass extends ParentClass{ /** * This is public and can be called from anywhere, yet has nothing to do with the parent class. */ public function doOtherStuff(){ print("<p>This is ChildClass() doing other stuff!</p>"); } /** * This adds additional functionality to the parent polymorphismAtWork() method. * It can completely replace the parent class method, but here we're doing some * work and passing the call to the parent version for it's own output. */ public function polymorphismAtWork(){ parent::polymorphismAtWork(); print("<p>ChildClass intercepts and says 'hello...'</p>"); } /** * Even though the child method is public, the parent is private. This will throw an * error. */ public function tryToAccessPrivateMethod(){ parent::privateFunction(); } } $inst = new ChildClass(); // This is ParentClass() calling! $inst->doStuff(); // Now ParentClass() is doing stuff! $inst->doOtherStuff(); // This is ChildClass() doing other stuff! $inst->polymorphismAtWork(); // ParentClass() says 'hi!' -> ChildClass intercepts and says 'hello...' $inst->protectedFunction(); // Fatal error: Call to protected method ParentClass::protectedFunction() from context '' in myExample.php on line xx $inst->tryToAccessPrivateMethod(); // Fatal error: Call to private method ParentClass::privateFunction() from context 'ChildClass' in myExample.php on line xx Output is in the comments.
  24. Don't instantiate Router from Init. Route extends Init, so all the functionality of Init is available to Router. You should be instantiating a Router object, not an Init object. In your Router::__construct() method, call parent::__construct(); This will fire the Init object's constructor, and you'll get access to $root and $directorySeparator.
  25. If you're wanting to play with color schemes, try out Adobe Color CC.
  • 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.