pwired Posted October 2, 2018 Share Posted October 2, 2018 Hi, The more you generate and concatenate pieces of markup, the less code is still highlighted by the editor. It doesn't matter what output strategy you work with, this problem stays the same. I think wireRenderFile and $files->render() keep the most code highlighted in the editor. Do you think that working with a MVC pattern will bring back better code highlighting in the editor ? How do you guys keep code still highlighted in your editor ? Link to comment Share on other sites More sharing options...
kongondo Posted October 2, 2018 Share Posted October 2, 2018 11 minutes ago, pwired said: How do you guys keep code still highlighted in your editor ? I've never had a problem with Visual Studio Code (nor Sublime Text before I switched to VSC). What are you using? Link to comment Share on other sites More sharing options...
pwired Posted October 2, 2018 Author Share Posted October 2, 2018 I am using the Bluefish editor. The code highlighting is working perfectly when I code plane html or php. But when these .= 'code ' . 'code ' { come in then I hardly have any code highlighting left. I am switching to wireRenderFile and $files->render because then I can code with highlighted code Link to comment Share on other sites More sharing options...
szabesz Posted October 2, 2018 Share Posted October 2, 2018 1 hour ago, kongondo said: Visual Studio Code (nor Sublime Text I no longer use PHPStorm but it is also able to properly highlight concatenated strings of source code. So it depends on the capabilities of the IDE/code editor. I simply use the alternative PHP syntax: http://www.brian2000.com/php/understanding-alternative-syntax-for-control-structures-in-php/ in which case highlighting is supported by all editors. 1 Link to comment Share on other sites More sharing options...
bernhard Posted October 2, 2018 Share Posted October 2, 2018 Maybe you want to paste code snippets and a screenshot to help us understand your problem better? I'm using VSCode and it looks like this: Another example with a multiline concatenated string: And another one appending some infos to a rendered field value: 1 Link to comment Share on other sites More sharing options...
pwired Posted October 2, 2018 Author Share Posted October 2, 2018 Hi bernhard, Thanks for stepping in Here php gets normally highlighted And selected in red when I put the cursor in front of a php tag Here html format still gets highlighted but the php part turns green like normal text strings Here both html format and php turns green and nothing gets selected in red when I put the cursor in front of a tag Link to comment Share on other sites More sharing options...
pwired Posted October 2, 2018 Author Share Posted October 2, 2018 I have seen this coding style in a basic-page.php file $output .= ' <div class="hero is-dark is-medium" id="intro" style="background-image: url('.$images[0].')"> <div class="is-overlay is-blue"></div> <div class="hero-body has-text-centered"> <h1 class="title is-1"> <a href="'.$page->url.'"> '.$page->get('headline|title').' </a> </h1> <p class="subtitle has-text-centered is-5"> '.$page->textfield_html.' </p> </div> </div> '; The coding is vertically between the $output .= ' and '; This way you can use normal code indentation horizontally per line What do you think ? Link to comment Share on other sites More sharing options...
bernhard Posted October 2, 2018 Share Posted October 2, 2018 46 minutes ago, pwired said: Here html format still gets highlighted but the php part turns green like normal text strings VSCode in my home.php template file (note the marked php start and end tag because I had my cursor there which is not visible in the pic): 49 minutes ago, pwired said: Here both html format and php turns green and nothing gets selected in red when I put the cursor in front of a tag That's ok because the green parts are just strings for your IDE! Same with VSCode: 23 minutes ago, pwired said: I have seen this coding style in a basic-page.php file $output .= ' <div class="hero is-dark is-medium" id="intro" style="background-image: url('.$images[0].')"> <div class="is-overlay is-blue"></div> <div class="hero-body has-text-centered"> <h1 class="title is-1"> <a href="'.$page->url.'"> '.$page->get('headline|title').' </a> </h1> <p class="subtitle has-text-centered is-5"> '.$page->textfield_html.' </p> </div> </div> '; The coding is vertically between the $output .= ' and '; This way you can use normal code indentation horizontally per line What do you think ? I think you should have a look at https://processwire.com/api/ref/files/render/g/ Take this example: And in your invoicetemplates.php file you could have clean code just like this: Why not give VSCode a try? ? 2 Link to comment Share on other sites More sharing options...
pwired Posted October 2, 2018 Author Share Posted October 2, 2018 Thanks for posting back on this bernhard and the link to $files->render() Yes with $files->render() I have at least the usual <?php echo between html tags I like this coding style: $var_topnavigation .= '<li><a href="' . $pages->get("/")->url . '"><img src="' . $homebutton->url . '"></a></li>' . "\n"; this way no <?php or <?php echo needed and you can normally use the html " quotes. You are right, it is time to move over to a better editor. I haven't seen how VSC handles inserting your own code snippets and editing directly online over FTP. I have seen a whole thread about VSC in dev talk so I will give it a try. Link to comment Share on other sites More sharing options...
bernhard Posted October 2, 2018 Share Posted October 2, 2018 6 minutes ago, pwired said: I like this coding style: $var_topnavigation .= '<li><a href="' . $pages->get("/")->url . '"><img src="' . $homebutton->url . '"></a></li>' . "\n"; I recently tend to do this, don't know about any best practises, though: 7 minutes ago, pwired said: You are right, it is time to move over to a better editor. I haven't seen how VSC handles inserting your own code snippets and editing directly online over FTP. I have seen a whole thread about VSC in dev talk so I will give it a try. That's the only thing where I'm not 100% happy so far. The available plugins that I tried are all somewhat clumsy/bloated/complicated. When I need to edit files directly I browse my server with WinSCP and then I can just double-click the file and it opens in VSCode. I can then edit and save this file from inside VScode and it gets uploaded automatically. For all other edits I switched to a git-setup, so I don't need direct edit via FTP any more. Meanwhile we also have Tracy+File Editor Panel for quick on-demand server edits. 2 Link to comment Share on other sites More sharing options...
elabx Posted October 2, 2018 Share Posted October 2, 2018 1 hour ago, bernhard said: That's the only thing where I'm not 100% happy so far. This is the sole reason also I'm stuck in prehistoric emacs setup, to easily work on servers, always a command away from connecting to a server and opening a folder. OMG it's finally here!! Gonna try this ASAP. https://marketplace.visualstudio.com/items?itemName=Kelvin.vscode-sshfs#review-details EDIT: OMG it works wonders, love this. 2 1 Link to comment Share on other sites More sharing options...
kongondo Posted October 3, 2018 Share Posted October 3, 2018 8 hours ago, bernhard said: That's ok because the green parts are just strings for your IDE! Same with VSCode: Although in some cases, it also depends on the 'theme' you are using that IDE ? 2 Link to comment Share on other sites More sharing options...
bernhard Posted October 3, 2018 Share Posted October 3, 2018 9 hours ago, elabx said: EDIT: OMG it works wonders, love this. Same here!! Awesome!! This makes vscode even more brilliant ??? Let's continue to discuss this in the vscode thread: 1 Link to comment Share on other sites More sharing options...
Recommended Posts