Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Benjamin Gröner Posted February 8, 2022 Posted February 8, 2022 Hi community, I am currently developing my first widget in a plugin. I want to use a phtml template to render the output of the widget. Unfortunately, it seems as if the phtml template is not loaded. I also tried to debug it and as I see it it searches for the template in the database, but the template is not in the database. What can I do, to help the system find my template. Here are some details about my case. I created the plugin via the ACP. Then I used the developer center to create a new widget with the Key tpArticlesSearchHero I see that all the files are created in the backend When I test the widget with a static output string, everything works fine so far. I add the file tparticles/dev/html/tpArticlesSearchHero.phtml to my plugin structure I add the line $this->template( array( \IPS\Theme::i()->getTemplate( 'plugins', 'core', 'global' ), $this->key ) ); to the init function of tpArticlesSearchHero.php After I did all this, I run into the exception "template_store_missing" Am I doing anything wrong here? Is anything missing here? Should the system add the template file information to the database? If yes how and when is it done? Hopefully anybody can help me. Thank in advance. Here are some screenshots of my setup
Marc Posted February 8, 2022 Posted February 8, 2022 I have moved your ticket to our developer connection forum, which is better placed for your request here. Benjamin Gröner 1
Miss_B Posted February 8, 2022 Posted February 8, 2022 I think that you are adding the template in the wrong location. At your widget php file, uncomment the following line inside the init function: $this->template( array( \IPS\Theme::i()->getTemplate( 'widgets', $this->app, 'front' ), $this->key ) ); Then inside the /dev/html folder, create a new folder called: front and inside that folder create another folder called: widgets and inside that folder create your template file ending in extension phtml. Hope it helps.
Benjamin Gröner Posted February 8, 2022 Author Posted February 8, 2022 Hi @Miss_B, thanks for your answer. Unfortunately that is exactly what I did, because that is what is written in the code comments. The only difference is, I did not uncomment the line you mentioned, but the second line, because I am developing a plugin and not an app.
Daniel F Posted February 8, 2022 Posted February 8, 2022 How does the template look like? Does it contain the proper header? Please share the first few lines.
Benjamin Gröner Posted February 8, 2022 Author Posted February 8, 2022 Hi Daniel, yes of course. My template looks exactly like this. <ips:template parameters=""/> <h1>MY NICE BLOCK!!!</h1> I just wanted to test it.
Benjamin Gröner Posted February 8, 2022 Author Posted February 8, 2022 Hey, I tested it now several times and the weird thing, that I found out is, that when I create the widget freshly via the developer center, then the template thing won't work. But if I download the plugin, then delete it and then upload the downloaded xml. Then it works . . . So for now I found a solution, but it's still weird.
Benjamin Gröner Posted February 8, 2022 Author Posted February 8, 2022 After I made the phtml template work, I've got now the problem, that changes in the template are not applied. If I change its content, I see still the content of the old template version. I see in the database, that there is still the old content in the core_theme_templates table, even if I clear all caches. So it looks like this update mechanism is kind of broken, at least on development instance. Again, if I download the plugin, then delete it and upload it again, everything workds and gets updated. If I change the template file in developer mode, nothing gets updated . . .
HeadStand Posted February 9, 2022 Posted February 9, 2022 Does the init method in your widget call the parent? If so... take that out. The parent method will override whatever you set as the template.
Recommended Posts