picarica Posted September 26, 2020 Posted September 26, 2020 so i am trying to put CustomHooksForVariations.module, a custom module, i am placing it into site/modules direcotry yet my modules page in admin panel gives me errors so this is the screen show when i refresh modules, i dont know why the shole hook is written on top of the page :|| and this next image is when i try to install it, i saw that it is not defiuned modules.php but it shouldnt need to be ?, any ways i dont want to edit site's core just to make one moulde work there has to be a way
teppo Posted September 26, 2020 Posted September 26, 2020 Just checking, but you didn't forget to add <?php at the top of your module file, did you? ? Note: I've moved this topic to the "Module/Plugin Development" forum area. The "Modules/Plugins" area is only intended for support threads of finished modules. 1
picarica Posted September 26, 2020 Author Posted September 26, 2020 51 minutes ago, teppo said: Just checking, but you didn't forget to add <?php at the top of your module file, did you? ? Note: I've moved this topic to the "Module/Plugin Development" forum area. The "Modules/Plugins" area is only intended for support threads of finished modules. okay i checked and no i didnt had ?php tags, i didnt even know i needed them, nowhere in guide i found any indiciations
teppo Posted September 26, 2020 Posted September 26, 2020 Glad you got it sorted! ProcessWire modules are written in PHP, and PHP code always requires the "<?php" start tag -- otherwise it's interpreted as plain text. In case you're embedding PHP within HTML you'll also need the closing tag "?>" (<h1><?php echo $page->title ?></h1>), but if the entire file is in PHP (as module files usually are) it's best to leave that one out. 1
adrian Posted September 26, 2020 Posted September 26, 2020 @picarica - you can also simply place the hook code in your sites ready.php file (https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/#new-core-files-for-site-hooks). There is no need to a create a dedicated module for this, although also no problem if you prefer this approach. 1
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