Jump to content

phpPunk

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

phpPunk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. For starters, you trying to use an array inside a string like a scalar...they don't use quite the same syntax for interpolation... [code]echo "$M[img]";[/code] Should be [code]echo $M['img'];[/code] Notice you don't need the double quotes around the whole thing...but you do need quotes inside the square brackets to properly index an associative field... If you have some reason where you absolutely need the array inside a string and wish to use interpolation still...I believe the syntax is... [code]echo "${M['img']}";[/code] Again...you still need quotes around the associative index but you also need curly brackets... Cheers :)
  2. [quote]Just to note, to my knowledge there isn't a Design Pattern other than MVC itself which covers "Template Engines"[/quote] Perhaps the author intended to say: http://en.wikipedia.org/wiki/Template_method_pattern I've investigated and worked or one a number of template engines (each with varying advantages/disadvantages) over the years...as I consider myself something of an expert in the field of template engine design I can say from experience there are indeed patterns which can observed which are specific to template engines. [quote]but it as a whole is a system, not a pattern[/quote] Ahhhhh....yes and no...a template engine can consist of countless existing "known" patterns and is a system. I agree with that logic. But by nature of the fact that design patterns are abstractions of real problems, which to me suggests vague definitions...nothing concrete...I see nothing wrong with assuming a template engine/system itself is one giant design pattern...it really depends on your POV. [quote]As for me, I've used Smarty in the past. It's not overkill because you use what you need to use.. a lot people hate Smarty, but not as many with real reasons to do so.[/quote] Find that comment I made on devnetwork.net amigo...my arguments were stedfast, accurate and undeniable. Smarty is indeed overkill and actually promotes bad design in some instances. But again, I guess it depends on your POV. Variable modifiers...??? If that doesn't scream "wrong domain!!!" I don't know what does... Leaving the template designer incharge of handling how currency value is rendered or how a date should be displayed??? WTF...that does little for internalization... :P And despite Smarty's trivial caching mechanism...it still sinks...I can implement time sensitive caching in about 5 minutes and I don't get the overhead of a huge complicated library. Why I say it's overkill? Simply because including the entire PEAR lib to use one function would be overkill IMHO. All Smarty does for you is offer a clean way to seperate concerns. Which bTemplate does too but with almost ZERO overhead. Smarty has the advantage (sole and only advantage from what I can tell) of having to compile Smarty templates into a PHP template anyways (ahem...bTemplate). The advantage this offers is that you can now safely allow anonymous users to upload new templates to custmoize their look and feel. Think MySpace...but how many web sites actually let you do that??? Considering MySpace is one in a billion...I'll take my chances in favour of bTemplate... As for the syntax argument...please...already noted...even a monkey could program in PHP and the Smarty tags are equally cryptic... An IF statement is an IF statement (intent is the same) regardless of how it is expressed syntactically...same goes for FOR loops, etc... Smarty does have some interesting expediant helper modules (or whatever their called) so you can render an series of OPTION tags without a FOR Loop...but again...easy to replicate in plain PHP... Yup...all in all...I see Smarty as a waste of effort and time...maybe if they added something useful...I'd use it...until then...I'm suggesting people stay *away* from Smarty like the plague :) Cheers dude :)
  3. Code reuse myfriend...code reuse... Using Zend (especially it's helper classes) can't hurt...
  4. [quote author=redbullmarky link=topic=119472.msg489454#msg489454 date=1166684131] 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. [/quote] Lucky...I was just about to chomp at the bit and say...that is bTemplate...but apparently we agree...so there will be no debating who is right or wrong *high fives*  ;D
  5. Ok...well I'm not sure what your after... Smarty is over kill...the only advantage it offers over bTemplate is allowing anonymous users to safely upload new templates....95% of web sites wouldn't have this requirement... Your template engine is extremely limited as a consequence of it's simplicity...it's secure and likely very efficient but too weak for anything but trival applications... You simply cannot render advanced GUI using a simple "push" and replace technique such as you have provided. Not without breaking some serious best practices mainly seperating PHP from HTML. How could you improve it? I told you...look into modeling after bTemplate. You need logic(although this is what I've investigated) in order to control advanced GUI's.
  6. I would suggest doing a quick Google for bTemplate it's a native PHP template engine which is simple and easy to follow... The number one goal of mine when designing a template engine is 100% HTML from PHP seperation...an enigmatic ideal. i'll keep working on my ideas until I discover a technique :) Cheers :)
  7. I don't nessecarily mean global in scope...but global is use...and global in namespace in the sense the functionality doesn't fall under any context or namespace other than global or system... For instance, I typically have a function like: [code] function redirect($url)   // TODO: Make sure URL is clean or adjust for mod_rewrite, etc   header("location: $url");   exit; } [/code] For security and ease of porting my application over from dynamic URL's to clean SEO URLS... Another example would maybe be a random string generator...some might argue that is functionality that belongs in a crypto library...I however see this as a global operation, feeling that a crypto lib should probalby provide it's own (some with more entrophy). So, given the two examples above...I ask...what are some "truely" global operations which you find being reused in your applications...and what is it's purpose? Cheers :)
  8. Not looking for a look into OR/M or this or that...what I'm looking for is some unique genuine ideas on how to solve the Single class per physical table problem... For instance, I like to keep each class focused on solely a single table (as much as I can) under some conditions it's merely enough to have dependenant classes return a array of associated ID's which the class can then use... What about when that isn't practical? Or is it? Perhaps denomalizing a schema would make sense...favouring code reuse/readability over finely tuned SQL queries pulling from various tables to return a single resultset... Again, not looking for advice on which OR/M or Data Mapper, etc...to use...i'm looking for input from someone who has personally considered, used, implemented their own DB solutions over the years and what techniques they find work best under given conditions... Cheers :)
  9. Only when I request files with a PHP extension. Other files are retreived as expected??? I figure it's mod_rewrite??? Anyone care to offer some insight? p.s-It's a shared host which I don't have access too (except FTP) so i can't poke aorund much more than I already have. Cheers :)
  10. hey man thanks for the reply... However, it's not the overlap of the 2 DIV's i meant...but rather the content which comes after the two div's is rendered underneath the DIV's I'll try what you suggested incase I'm missing something
  11. [quote]<div style="position: absolute; width: 50%; height: 320px; border: 1px solid black">   <div><img src="" width="340px" height="280px" /></div>   <div>Map</div>  </div> <div style="position: relative; width: 50%; height: 320px; border: 1px solid black; float: right">   Google AdSense  </div>[/quote] <b>This is rendered incorrectly as it's not at the bottom???</b> This works but all content after this is displayed as though the DIV's don't exist (underneath them?) What change can I make to correct this issue?
  12. Each item is associated with a single categorey, but if an item is placed under say "Child" which is a child of category "Parent" then when someone is viewing "Parent" they would also see all of it's child items as well... Currently I have a function pull all of a "Parent" child ID's and pass that to a IN(1,2,4,5,6) clause... Obviously not overly efficient, but I can't think of anything else, outside of associating each ad with multiple categories instead of just using a single category ID... Assuming I like the IN(x,x,x,x) approach what are some MySQL specific (or SQL ingeneral) optmizations I can apply to speed things up??? Make sure each catid (ie: catid IN(x,x,x,x)) is an index? Anything else?
  13. Well PHP is the wrong technology for that, but if you must... I'd suggest scanning each file at upload and storing what you can in a database....users searches are done on the DB not the native file system. Portable, faster indexing, etc... It'd be very difficult to write something as efficient as a RDBMS even using C.
  14. [quote author=448191 link=topic=117089.msg477634#msg477634 date=1165086099] [quote author=phpPunk link=topic=117089.msg477478#msg477478 date=1165046730] One problem I have with including modules as required in each class is that relative paths are a PITA and using an absolute path in this way is murder. [/quote] PITA? please elaborate. Also, I don't see any problems with autoload, I think it's a fantastic feature that should be taken advantage of. [/quote] autoload...is a feature of PHP which I care not to use...if you find it useful by all means use it... :)
  15. In a purely business sense, aesthetics are *everything* and way more important than functionality, a business is about branding not about technicalities. 1) An image may have anti-aliasing, text is rendered by the browser...if that feature is disabled...text looks GROSS!!! 2) An Image is consisten across the board - same reasons as above. 3) A properly used/optimized image will take *alot* more space than text, but not enough to be a significant factor is choosing bettwen one or the other. 4) Text is SEO/Friendly an Image on it's own is nothing but bytes. You need to use ALT attributes, etc... 5) Images are difficult to convert on the fly (say for multi-language support) and *will* drive up your long term maintenance costs. I vote images when I can absolutely get away with it, which is typically the norm. Sorry man, I agree with your boss man :)
×
×
  • 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.