Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
TomTucka18 Posted November 29, 2018 Posted November 29, 2018 I'm building out a community that needs some custom pages - the pages will be accessing the DB but also have custom designs. What is the best way to do this? I cannot get it to work using the following methods: Custom Page Only - This accepts all HTML and JS code but any PHP added just gets ignored/ not displayed. Custom Page with Blocks - blocks accept PHP but don't allow any HTML at all. Workable but would need a custom block for each new bit of php. Ideally someone will be able to point out how simple it is to allow PHP on custom pages and how stupid I am for missing it. Thanks in advance.
opentype Posted November 30, 2018 Posted November 30, 2018 The best option is to learn and use the template syntax IPS uses in all its templates:
TomTucka18 Posted November 30, 2018 Author Posted November 30, 2018 Thanks but I'm not sure that is what I'm looking for. I have tried to create a new "template" and assign when creating a page that uses that template but the template is not visible in the drop down. Is there no way to just create a "page" that allows be to write php/html/js directly?
opentype Posted November 30, 2018 Posted November 30, 2018 Don’t get confused by the word template. Just create a new page in the mode “manual HTML”. There you can add your custom HTML and your custom PHP. But the PHP needs to be in {{// this mode;}}, not <?php this one ;> CSS and JS are created in the template section and then you can include any CSS or JS file for each custom page you have created.
TomTucka18 Posted November 30, 2018 Author Posted November 30, 2018 Wow i must have been half asleep when I tried this earlier. Thanks both for the explanation and examples. I'm guessing there is some php that doesn't work, for example print and echo statements seem to be ignored.
opentype Posted November 30, 2018 Posted November 30, 2018 10 minutes ago, Flax said: I'm guessing there is some php that doesn't work, for example print and echo statements seem to be ignored. Yes. Because they make no sense in the way this is handled. But this works. {{$test="Hello world";}} {$test}
TomTucka18 Posted November 30, 2018 Author Posted November 30, 2018 Great, thanks. I'm starting to understand the IPS syntax now. That makes a lot more sense. Once again thanks for the help.
Ryan Ashbrook Posted November 30, 2018 Posted November 30, 2018 Also, keep in mind the expression plugin, which is useful for outputting the return value of functions - for example: {{$list = array( 1, 2, 3 );}} {expression="implode( ', ', $list )"} Will output: 1, 2, 3
bfarber Posted November 30, 2018 Posted November 30, 2018 And one last tip - you can create blocks that support raw PHP as you noted, but contrary to what you said you can use HTML there too. You would simply echo/print it. // Imagine some complex PHP code here. print <<<EOF <strong>and here's the HTML finally...</strong> EOF; // I could do more with PHP if I needed to
Tom S. Posted November 30, 2018 Posted November 30, 2018 I include external PHP into the page and that means I have no restrictions. This way you can code PHP freely: <? echo 'Anything goes!'; ?>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.