Test for component - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Scripts & Components (http://get-simple.info/forums/forumdisplay.php?fid=11) +--- Thread: Test for component (/showthread.php?tid=10490) |
Test for component - tibbz - 2018-05-24 Is there a way for testing if a component if being used? I set a global var in functions.php to False and changed it in a component to True so some css and js is loaded. The template already seems to be compiled. Rgds Tibbzy RE: Test for component - shawn_a - 2018-05-24 That should work, the component is only evaled when something uses it RE: Test for component - Carlos - 2018-05-24 @tibbz How do you insert the component? With get_component('name'); in your template, or some other way?
RE: Test for component - tibbz - 2018-05-25 I'm using the DynPages plugin http://get-simple.info/extend/plugin/dynpages/81/ {% component param %} using it in the page itself. RE: Test for component - Carlos - 2018-05-25 Then, the component is executed in <?php get_page_content(); ?> , so if do your check before that, it will not work.A possible way to do what you need would be a conditional that checks if the string "{% componentname " is present in global variable $content RE: Test for component - tibbz - 2018-05-28 Yes this works very well thank you. Set a flag if you need to check after <?php get_page_content(); ?> as the component code will have been evaluated. I say this because css and js are loaded at different times in the page. |