Jump to content

redbullmarky

Staff Alumni
  • Posts

    2,863
  • Joined

  • Last visited

    Never

Everything posted by redbullmarky

  1. if it doesnt prompt you, then in the past you've clicked the 'always do this' or whatever it says. cant remember on the PC, but should be the same - go to the 'site' part of the preferences (not manage site, but the actual prefs) and look for 'dependent files'.
  2. not so much with web stuff. i dont know why, but when i was properly into Pascal (college) and later C++, I would say yeah - I was quite competitive in that respect. But I'm not so strict as far as web stuff goes, just as long as it's solid, reusable and does the job. I guess it's probably somewhat different for me in the fact that I actually work for myself from home.
  3. Jenk, neither <? nor <?= are going to be removed in PHP6 unless things have moved on from the meeting and the minutes that were made available. The discussion was with regards to removing <% and < script language="php" > and adding <?php= . Sure, I'm fully aware that they're not recommended by many - but with the popularity of Ruby (thanks to Rails in particular), and with people loving the short and alternative syntax, I'd take a stab that even in further versions of PHP they'll still be around and as it stands at the moment, most versions of PHP4 and 5 have the directive turned on by default. I've been with several hosts and none have had it turned off as yet, but I can appreciate that some may do. However - with current practices and SEO with tidy URL's, most good hosts support and give the ability to maintain htaccess files which does also allow you to set the short_open_tag setting if it's disabled by the main PHP.INI. Sure - not ideal - but neither is a host that lumps you with the default settings with no way of changing anything. If something has happened since the meeting, I'll stand corrected.
  4. no worries, dude. like i say - the idea of 'layouts' will work regardless of whether you go the smarty or php way. I based this idea on frameworks like CakePHP/Rails/CodeIgniter, etc which are all based on the MVC design pattern good luck!
  5. yeah you're totally right. to me, for all the overhead you save, typing <?=$pagevar ?> isnt that much harder than typing {PAGEVAR}, even for a PHP-unaware designer. some argue against using PHP short tags, but looking over the minutes of the meeting regarding PHP6, there are no plans to do away with them and are generally turned ON by default. couple that with PHP's [url=http://usphp.com/manual/en/control-structures.alternative-syntax.php]alternative syntax[/url] and you have something quite simple indeed without the headache and bloat of Smarty.
  6. infact, code might make it a little clearer. my Config is a singleton. the two relevent parts of it here are 'page' which stores default variables (ie, such as copyright message, etc) and 'view' which has settings such as whether to use gzip or not. [code] <?php class View extends Core {     public $vars = array();     public $html;         private $controller = null;         public $layout = null;         private $config = array();             function __construct(&$controller)     {            parent::__construct();                        $this->config = Config::load('view');                 $this->controller = $controller;                 if (!isset($this->config['layout']))         {             $this->config['layout'] = 'master.tpl.php';         }         $this->layout = $this->config['layout'];                         $pagevars = Config::load('page');                 if (sizeof($pagevars))         {             $this->vars = array_merge($this->vars, $pagevars);         }     }         /*     * loads a template file and returns the output     *     */     function load($filename)     {         extract($this->vars);         ob_start();         include($filename);         $this->html = ob_get_clean();                         return $this->html;     }     function loadtovar($varname, $filename)     {         $html = $this->load($filename);                 $this->set($varname, $html);     }     /*     * sets a view var     *     */     function set($varname, $value = '')     {         if (!is_array($varname))         {             $this->vars[$varname] = $value;         }         else         {             foreach($varname as $key=>$var)             {                 $this->vars[$key] = $var;             }         }     }             /*     * displays the final output     *     */     function render($return = false)     {         global $TIME_START;                 $this->vars['pagebody'] = $this->html;         if ($this->layout)         {             ob_start();             echo $this->load($_SERVER['DOCUMENT_ROOT'] . '/app/views/' . $this->layout);             $html = ob_get_clean();         }         else         {             $html = $this->html;         }         $html = str_replace('{PAGE_GEN}', round(getMicrotime() - $TIME_START, 4), $html);         if (!$return)         {             if (isset($this->config['gzip']) && $this->config['gzip'] == true)             {                 ob_start();                 ob_start('ob_gzhandler');                 echo $html;                 ob_end_flush();                 header('Content-Length: '.ob_get_length());                 ob_end_flush();                    }             else             {                 echo $html;             }         }         else         {             return $html;         }     } } ?> [/code] and an example use from within my controller: [code] <?php $view = new View($this); $view->set('message', 'Hello World!'); $view->set('thoughts', 'The world is flat'); $view->loadtovar('pagebody', 'mypage.tpl.php'); echo $view->render(); ?> [/code] which makes the vars 'message' and 'thoughts' available to mypage.tpl.php, which in the end is plugged into 'pagebody' which is a common name i use to plug content into a master layout. it aint perfect, but hope it gives you an idea of where i'm coming from. cheers Mark
  7. i totally understand you - only I do think (in a loser definition of what patterns/problem solving is all about) that it is kinda relevent, as it does have a baring on how you structure things. @phppunk yep - no arguments from me. The whole "yeah but it seperates php from html" argument doesnt wash with me, as it's replacing one syntax with another. or "my designer doesnt know PHP" which doesnt either, as PHP is VERY easy to learn, especially with its alternate syntax. @generic again, it's not that I find your class bad, but i'm dead set against the whole method of templating like this (although i never used to be). As far as going a step further with yours (whether you keep it as smarty-type tags or PHP tags: I'm well into the whole idea of using 'layouts' - that is, having a 'master' layout (including all the doctype/CSS/JS includes, logo, possibly the nav, etc, and a 'template' in my book is a snippet that lives inside of it. my master template generally looks something like: master.tpl.php [code] <DOCTYPE etc etc> <html> <head> <?=$pagehead ?> </head> <body>   <div id="wrapper">       <div id="header">         <img src="logo.gif" alt="logo" />       </div>       <div id="content">         <?=$pagebody ?>       </div>       <div id="footer">         Copyright 2006 blahblahblah       </div>   </div> </body> </html> [/code] and my template for a page might be: [code] <h1>My Page</h1> <hr /> content goes here<br /> hello world! [/code] i have methods for setting/getting variables, i have a loadToVar method which loads HTML from a template into a variable (for partials, repeating regions, little panels, etc - similar to what you've done with your line that does setVariable('PAGEBODY', ...)). Now that I have my main page ready, a single call to my 'render' method literally just plugs the HTML into my master layout by setting the 'pagebody' var. trust me, it's easier than that in practice than it is to explain :) but the whole template class is something like 130 lines, is fast, supports gzip, layouts, etc.
  8. here's a good article. I always pull this article out of the drawer when it comes to template engines: http://www.massassi.com/php/articles/template_engines/ There is nothing in that article I disagree with, which is unique for me. Looking at it again, this dude is the author of bTemplate.
  9. artacus, you just KNOW that they're gonna be filing multi-million $£ action. Just to go with the ones like suing McDonalds for making people fat, suing the Cigarette companies because you get ill. The compensation culture is a little more wild over that side of the pond, but it's silly here too. I've heard of people getting sued HUGELY for less offence than that, but normally a gift card and a nice pre-printed standard complaint apology letter is all they get which makes me laugh ;D Maybe I should try suing Carlsberg for making me drunk the other day . "£25 gift vouchers??? nah! Just another 24pack will do"
  10. thats exactly what i mean for the array, yes. just keeps things tidier and allows full access to ALL table params if required, not just its class.
  11. looks useful, if limited. if you could make the 'rounded_table_start' more generic and useful for all types of containers, like DIV's, etc, that would be good. also - consider the last (optional) parameter of the rounded_table_start. if instead of 'css_class', you accepted an array of params, the user could ALSO tweak other standard parts of the table - cellpadding, cellspacing, etc, and the width could also be combined into it. otherwise, good work. i know how tricky it can be to get perfect rounded corners with CSS...
  12. and 3) you dont look as good as your receptionist in a bra?
  13. @Crayon: spot on about self-learning. @graham: yeah i was pretty chuffed. I phoned around several places getting quotes and that was the average. One place wanted just shy of £10,000 (approx US$19,500) for what i was asking. The result of doing it myself is here: http://www.legacyrecruit.com (please excuse the apparent plug. our primary business is Construction/housing, so i actually have nothing to gain apart from providing an example of a self-taught, DIY site)
  14. self taught here. saved myself a quoted £5000+ in the process by building my recruitment company website myself. I tend to prefer learning off my own bat, as that way I truly understand what i'm doing. Too many people are too trigger happy with Copy+Paste, and whilst I appreciate what schools/colleges teach, they tend to emphasise on the "proper/best practice" way using rubbish scenarios, which isn't ALWAYS the best solution to real problems.
  15. ;) no probs
  16. in addition, the actual php.ini (as with the httpd.conf with apache) is fantastically commented already. writing code to work with the php.ini as it is (notably the recommended version that comes with a fresh installation) is best - if you have to keep changing things for each project (other than turning errors/error levels on/off/up/down, then it's probably your code that needs changing, not the INI file. in addition - files like that - if you dont know what something is, leave it alone. when you need to change something at that level, you'll just know what it is and exactly where to look.
  17. 0 is classed as a 'false' value so if x is 0 in the URL, $_GET['x'] when using 'if' will return false. for what you want to do, try: [code] if (isset($_GET['x']) and isset($_GET['y']) and isset($_GET['field'])) [/code]
  18. you need to change the permissions (with chmod) of the destination directory to writable (777 will do the trick)
  19. unless i'm missing the point - they already ARE associative arrays...
  20. have a look at the [url=http://www.php.net/nl2br]nl2br[/url] function, which will do exactly what you're after. Cheers Mark
  21. but isset does exactly that - it tells you if a var is set (ie, holds a value). [url=http://www.php.net/isset]isset[/url] returns either true or false. so what your check actually equates to is: if TRUE/FALSE == 'yes' which will always fail. using both a check of being set as well as a check of its value should work: [code] <?php if (isset($_SESSION['auth']) && $_SESSION['auth'] == "yes") ?> [/code] hope that helps Cheers Mark
  22. although a different type of thing, a petition site i saw recently had a good type of spam prevention, and as comment/guestbook type things are more one-off post type things, it seems to work...basically an email is sent to the email address specified in the form, with an activation link. works EXACTLY the same as forum registration activation emails. most spam bots are either using forged email addresses, or just fake ones, in which case, it works very nicely. as far as guestbooks and things go, i dont think i'd ever actually post a comment to a site of mine straight away. the dinnertimes site of mine puts ALL submissions by a user in a moderation queue for me to click 'approve' or 'deny'.
  23. what have you tried so far? got any code to show?
  24. it could be a case of your error_reporting level as to why you're getting the error on one and not the other. you could always do a check just before the 'foreach' such as: [code] <?php if (sizeof($this->Cart) == 0) {   return; } ?> [/code] the invalid argument would be a result of the foreach being passed something other than an array (including a null value). you can also try changing the $Cart declaration in your class to: [code] <?php   private $Cart = array(); ?> [/code]
  25. here's another one. i believe it probably uses the same method, but just involves throwing a JS include at the top of the page: http://homepage.ntlworld.com/bobosola/pngtest.htm i like the way they've done it in the article you've linked to though as there's always something slightly dodgy about using JS to patch things up. good shout.
×
×
  • 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.