bwakad Posted April 13, 2014 Share Posted April 13, 2014 I now started to use normal html and use the normal php inside: <img id="photo" src="<?php echo $child->image->getThumb('thumbnail');?>" /> this saves me from mistakes. Because using either double or single qoutes, with more and longer lines where you would have 2 or maybe 3 parts of php AND maybe some classes for CSS it get's confusing. I used to do $out = ."html code {php code} etc. and on the next line about the same. Eventually making echo $out; I believe they call it something like concacating? Then I read on internet single qoutes are faster because double qoutes need to be readed all the way before output takes place. But again, the qoutes get's me confused when combining everything. It's also better to use $out = instead of $out .= So what is the way you all doing it without errors - what is the better way? Link to comment Share on other sites More sharing options...
Roope Posted April 13, 2014 Share Posted April 13, 2014 (edited) bwakad, I don't want to sound rude but how do you think this kind of questions are actually even related to ProcessWire? I know this is off topic section but still.. I suggest you buy yourself some PHP book for beginners and get the basics right - it helps you a lot with PW! http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dstripbooks&field-keywords=php Edited April 13, 2014 by Roope Link to comment Share on other sites More sharing options...
Joss Posted April 13, 2014 Share Posted April 13, 2014 Oh, php and processwire are rather intimately connected, I would say. I am certainly not an expert, but the way I work is that where I am putting together my PW output within a function, then I will work much as you describe $out = ""; $out .="<h1 class='myclass'>{$page->title}</h1>"; echo $out; Those functions frequently sit in an included file somewhere. When I write into a template, however, then I will often just break into php mid markup as you have done. My useless rule of thumb tends to be "however I do it, make sure it is really, really obvious so that when I come back to it next week, I can work out what I was up to!" But then, only I have to read my code. If I was working with someone else, I should probably be more regimented. Link to comment Share on other sites More sharing options...
Roope Posted April 13, 2014 Share Posted April 13, 2014 Oh, php and processwire are rather intimately connected, I would say. You're right, I edited my answer. Dealing with ProcessWire has taught me LOT from PHP but starting with PW can be real struggle without any basic knowledge of the language. It's really hard to build a house if you don't know how to hold the hammer Link to comment Share on other sites More sharing options...
pwired Posted April 14, 2014 Share Posted April 14, 2014 a good read http://www.flamingruby.com/blog/php-for-template-designers/ also don't forget hanna code http://modules.processwire.com/modules/process-hanna-code/ Link to comment Share on other sites More sharing options...
Joss Posted April 14, 2014 Share Posted April 14, 2014 You're right, I edited my answer. Dealing with ProcessWire has taught me LOT from PHP but starting with PW can be real struggle without any basic knowledge of the language. I am working on that. Ummm ... slowly. Link to comment Share on other sites More sharing options...
bwakad Posted April 14, 2014 Author Share Posted April 14, 2014 Looks like I am old fashion, I often think "was not PHP invented as such?" : <ul class="inline"><li><?php echo "something funny";?></li><ul> When I would have used single qoutes or the way Joss's example it get's complicated. btw, I see a lot of people on this forum use Hanna's code, but is it not just something like wordpress has? Link to comment Share on other sites More sharing options...
Roope Posted April 15, 2014 Share Posted April 15, 2014 I am working on that. Ummm ... slowly. I hear you - your sig is my thoughts exactly. But we're getting there and PW makes learning PHP so damn fun that we can just smile and enjoy the ride! 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted April 15, 2014 Share Posted April 15, 2014 I love the ProcessWire road with the by-product of learning PHP. ProcessWire makes me eager to learn. And for the question: I don't like HTML in my template, I like php strings of HTML better. At the end it just makes it more readable. Mostly <?php is only used ones at the top of the file and thats it. 1 Link to comment Share on other sites More sharing options...
robinc Posted May 6, 2014 Share Posted May 6, 2014 I don't like HTML in my template, I like php strings of HTML better. At the end it just makes it more readable. Mostly <?php is only used ones at the top of the file and thats it. What do you use to write code in? I am using Notepad++, which gives very useful readable syntax highlighting, and tag/bracket pair matching, but does nothing to help make php strings of HTML more readable. Any suggestions? Link to comment Share on other sites More sharing options...
Martijn Geerts Posted May 7, 2014 Share Posted May 7, 2014 BBEdit & Sublime Link to comment Share on other sites More sharing options...
kongondo Posted May 7, 2014 Share Posted May 7, 2014 I use Sublime mainly, but also use Np++ sometimes. PHP strings of HTML are highlighted just fine. Better if you concatenate variables within the strings (if any) rather than use curly braces..i.e. Rather than.... "My string is about {$page->title} and other stuff"; use this.. "My string is about" . $page->title . "and other stuff"; Link to comment Share on other sites More sharing options...
bwakad Posted May 7, 2014 Author Share Posted May 7, 2014 But in sublime you can set whatever you want to certain highlighting - which is also readable. I now use google profile because it's one of the more clear ones. Unless you use php strings... 1 Link to comment Share on other sites More sharing options...
Recommended Posts