LMX Posted December 7, 2020 Share Posted December 7, 2020 Due to financial constraints my organization cannot support a self hosted option but I am still looking to develop additional features for our instance. Any advice on good ways to go about this? Right now I am using custom blocks but this requires a terrible conflation of HTML/CSS/JS into one file which is less than ideal. Another issue is there doesn't appear to be any way to utilize BE & FE code for one feature as custom blocks make you utilize just PHP or HTML. Is there a way to utilize ENV variable to hide my API keys in the custom blocks I make? I know this is a broad question and the answer may just be that I am SOL but I wanted to check in with all of you first before banging my head any further. Thanks! Link to comment Share on other sites More sharing options...
Solution bfarber Posted December 8, 2020 Solution Share Posted December 8, 2020 Within Pages, if you go to Templates in the AdminCP you can create custom CSS and javascript files. When you create individual pages later, you can then choose which CSS or javascript files you wish to embed on which pages, which allows you to separate these resources. That said, this doesn't directly help if you intend to take that custom block and embed it on a different page (i.e. using the sidebar widget manager). You can, however, include those resources still by calling the appropriate URL generator method. It's a bit long winded but would be possible. You can create HTML and PHP blocks, and naturally you can embed the two together (either using template logic in an HTML block, or regular PHP methods to output in a PHP block). It's worth noting one block can also embed another block. For instance <h2>Title</h2> {block="my_other_block"} You could use this method to hide an environment variable in one block and then embed it in another block, although I'm not really confident this gains you much - if someone could access the first block in the AdminCP, they can access the other block as well. Hopefully this helps! LMX 1 Link to comment Share on other sites More sharing options...
LMX Posted December 8, 2020 Author Share Posted December 8, 2020 Thanks bfarber, this is very useful. Would you mind providing me an example of what it would look like to call resources into a custom block via "URL generator" methods? Link to comment Share on other sites More sharing options...
bfarber Posted December 9, 2020 Share Posted December 9, 2020 $template = \IPS\cms\Templates::load( $key ); $object = $template->_file_object; $url = (string) \IPS\File::get( 'cms_Pages', $object )->url; $key being the appropriate template key LMX 1 Link to comment Share on other sites More sharing options...
LMX Posted January 13, 2021 Author Share Posted January 13, 2021 (edited) @bfarber apologies for resurrecting an old thread - quick question. On 12/8/2020 at 6:44 AM, bfarber said: <h2>Title</h2> {block="my_other_block"} If in this example "my_other_block" is a php block which returns an array like below... how would I access the data from that array in the phtml block? $exampleArray = Array( 'foo' => 'bar', 'baz' => Array( 'nestedFoo' => 'nestedBar' ) ); Edited January 13, 2021 by LMX Zdeněk Tůma 1 Link to comment Share on other sites More sharing options...
bfarber Posted January 14, 2021 Share Posted January 14, 2021 you'd probably need to do something like this in your block $_SESSION['arrayValues'] = ...;// The array data and then look at $_SESSION['arrayValues'] in the rest of the block/template after. I just used $_SESSION as a globally accessible storage container in this case, you could use other similar paradigms. LMX and Zdeněk Tůma 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts