JFS Posted January 13, 2014 Share Posted January 13, 2014 Hello Everyone, I'd like to dynamically generate some content for display in a CMS page. I will be generating the content in custom PHP code. Any suggestions or hints? Where would you recommend I look for a "How To"? I haven't really seen any information related to displaying dynamic content in a CMS page - just posting to PHP from CMS pages... Thanks for all your responses Best regards, John Link to comment Share on other sites More sharing options...
vekia Posted January 14, 2014 Share Posted January 14, 2014 copy code from your external php file to CmsController.php located in your controllers/front directory. pass variable with results to smarty array, then you will be able to use it in cms.tpl file Link to comment Share on other sites More sharing options...
JFS Posted January 14, 2014 Author Share Posted January 14, 2014 Alright.. I'm not getting this. Have a look at: http://9thchakra.com/content/10-consult-your-favorite-oracle and now look at http://9thchakra.com/oraclecards.php I want to embed the output of oraclecards.php into the http://9thchakra.com/content/10-consult-your-favorite-oracle and have it work the same way it does now. I believe you are telling me to insert my code into the CMSController.php file and then in the initContent() routine assign the output to a smarty variable like this: $this->context->smarty->assign('cardgrid', ????); but I'm not sure what I should have in place of the ????. Finally, I don't know how to distinguish (in the cms.tpl file) which CMS page I'm on... I'm beginning to think that this is the wrong way to go. Is there any other way to create custom pages within the context of the site that can run this kind of custom code? Thanks! John Link to comment Share on other sites More sharing options...
krisives Posted January 14, 2014 Share Posted January 14, 2014 Are there any CMS hooks? Link to comment Share on other sites More sharing options...
JFS Posted January 14, 2014 Author Share Posted January 14, 2014 Not sure I understand your question... Please be aware I am very new to PrestaShop so I'm not aware of all the intricacies. Link to comment Share on other sites More sharing options...
krisives Posted January 14, 2014 Share Posted January 14, 2014 Sorry, I am asking vekia if he knows about any CMS hooks. Hooks let you insert content to areas of Prestashop. Link to comment Share on other sites More sharing options...
vekia Posted January 16, 2014 Share Posted January 16, 2014 Are there any CMS hooks? nope, cms "content" part hasn't got any hook available to use. on cms page you can use only "global" hooks like left / right columns, top, header and footer. nothing more by default. Link to comment Share on other sites More sharing options...
JFS Posted January 16, 2014 Author Share Posted January 16, 2014 Any thoughts on creating a new page / set of pages this way? http://alvinjiang.blogspot.com/2011/01/prestashop-tips-how-to-create-complete.html It perhaps looks more like what I'm trying to accomplish... Thanks! John Link to comment Share on other sites More sharing options...
vekia Posted January 16, 2014 Share Posted January 16, 2014 guide you attached are related to old prestashop version. new prestashop (1.5+) doesn't work like that and guide you attached isn't good solution. Link to comment Share on other sites More sharing options...
JFS Posted January 16, 2014 Author Share Posted January 16, 2014 Any guides for the new version? Some similar process? Link to comment Share on other sites More sharing options...
vekia Posted January 16, 2014 Share Posted January 16, 2014 take a look here: http://www.prestashop.com/forums/topic/273904-show-all-products-in-prestashop-155 you can download project files, you will see how to create a controller there this is proper way 1 Link to comment Share on other sites More sharing options...
JFS Posted January 16, 2014 Author Share Posted January 16, 2014 Thank you for your guidance Vekia. I'll post a link for your critique once I've learned how to do this. All my best, John Link to comment Share on other sites More sharing options...
vekia Posted January 16, 2014 Share Posted January 16, 2014 the most important things: - create controller - create .tpl file to display contents and in fact, that's all this library is worth to check it an analyse the code there :] Link to comment Share on other sites More sharing options...
JFS Posted January 19, 2014 Author Share Posted January 19, 2014 Hi Vekia, I'm having some trouble separating the wheat from the chaff in the example. Can you post an empty example? Thanks! John Link to comment Share on other sites More sharing options...
vekia Posted January 20, 2014 Share Posted January 20, 2014 hello have you checked this file from thread that i attached above? does it work for you? Link to comment Share on other sites More sharing options...
JFS Posted January 20, 2014 Author Share Posted January 20, 2014 Hi Vekia, I have downloaded the example and tried to modify it but without knowledge of how PrestaShop internals work, I'm at a loss. I can include my code in a zip file but I think it may be better to see a "Hello world" type of example. Thanks for all your help. Best regards, John 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