genericFJS Posted January 11, 2019 Share Posted January 11, 2019 Hi, for easier editing with external code-editors (with benefits such as syntax highlighting and additional scripting-capabilities) I am saving my (Text-)content to a (php-)file instead of editing it in the backend. My current solution looks like this: My page templates have a file upload where I upload the php-file. The php file gets read in my page template like this (with a fallback for the regular body content): if ($page->bodyPHP) { ob_start(); include(getRelativeAssetPath($page->bodyPHP->url)); $content = ob_get_contents(); ob_end_clean(); } else { $content = $page->body; } This leads to the problem, that I can not edit my page (text-)content with the backend any more, if I am not at my desktop with FTP-access to the website. Here are a few questions regarding this challenge: Can I create a (modified) textarea-inputfield to load and save content from/to a php file instead of the database (possibly automatically without an explizit file-inputfield)? I tried having a look at the inputfield source code but did not manage to get a hang of it. Is this solution a (very) bad idea performance-wise (I'm not concerned about the backend-security that much since I am the only editor)? Are there solutions, that make my workaround superfluous? I would be really glad if someone could answer some or all of my questions. Thank you. Link to comment Share on other sites More sharing options...
kongondo Posted January 11, 2019 Share Posted January 11, 2019 Hey @genericFJS. Welcome to the forums. 1 hour ago, genericFJS said: Is this solution a (very) bad idea Yes. I think it is a bad idea. 1 hour ago, genericFJS said: for easier editing with external code-editors (with benefits such as syntax highlighting and additional scripting-capabilities) It seems to me that you are including PHP in your content? Any reason why you need to do this? If you wanted some logic within the text, you can use Textformatters instead (like Hanna code). Link to comment Share on other sites More sharing options...
genericFJS Posted January 11, 2019 Author Share Posted January 11, 2019 @kongondoThanks for your reply. You are right, I am including PHP in my content. The main reason for this is, that I hate the built-in multilanguage-support as it does not separate formatting from content (i.e. when I want to move a picture in the german version, I have to move the picture in the english version explicitly as well). There are other reasons too (i.e. image sizing). Your suggestion seems to be a very good idea for these, thanks. If there were a system to handle my main concern (inline translation) and a syntax highlighter for the backend editor* I could be pursuaded to drop my php-file-idea entierly ? Thanks again for your consideration. * I have found i.e. Prism but not yet tried it as my localization-needs are my main concern. Link to comment Share on other sites More sharing options...
kongondo Posted January 11, 2019 Share Posted January 11, 2019 6 minutes ago, genericFJS said: I hate the built-in multilanguage-support as it does not separate formatting from content (i.e. when I want to move a picture in the german version, I have to move the picture in the english version explicitly as well) Are you talking about inline-images? Link to comment Share on other sites More sharing options...
genericFJS Posted January 11, 2019 Author Share Posted January 11, 2019 @kongondo I'm talking about images, code (as in <code></code>) or other language-independent HTML-elements surrounded by text/paragraphs etc. Link to comment Share on other sites More sharing options...
kongondo Posted January 11, 2019 Share Posted January 11, 2019 My question was about the pictures you were talking about. Are those inline pictures as opposed to pictures (images) saved in an Image field. It is sort of a tangential question :-). Link to comment Share on other sites More sharing options...
genericFJS Posted January 11, 2019 Author Share Posted January 11, 2019 @kongondo Yes, I meant inline pictures (or other inline elements as described) which were uploaded in a seperate image field which I inserted like this: <img alt="<?php echo $page->images["image.jpg"]->description; ?>" class="d-block w-100" src="<?php echo $page->images["image.jpg"]->size(1200,1200)->url; ?>" /> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now