PyroCMS Custom Module Layout - pyrocms

I created a custom module called Drawings. I wanted to give it its own theme layout on the frontend, so I followed the advice I found HERE - I put a layout file titled Drawings.html in my theme.
This had the correct effect on the frontend, but caused other problems and questions that I've been struggling to sort out:
The backend admin section for my module now uses the Drawings.html layout, which breaks its functionality completely. How can I set a specific layout for my module front end, but keep the standard admin backend layout (same backend implementation as in the sample module tutorial)?
I read the following in the Template Library: "When using Public_Controller and Admin_Controller, the layout is already set." Perhaps the solution involves using the set_layout function in these controllers somehow? All my attempts failed so far though.
I feel I am doing something incorrectly because now my module is not modular. For example, after creating the Drawings.html layout file in the theme, a statement like {{ theme:css file="drawings.css"}} in that layout file searches for those resources in my theme. So I have to put those JS and CSS resources in my theme, instead of in my module's CSS and JS folders. How do I keep and access my resources in the module's JS and CSS folders?
I don't know how this is supposed to work.

When you are using front end controller use a layout there using philsturgeon template library like this
function index(){
$this->template->set_layout('drawing')
->build('yourview');
}
This way you can load a custom layout for your application.

Related

Override JE Quick Contact module in Joomla 3x

My client is using the module Je Quick Contact in their site, in Joomla 3.7.3
As default, the sender email is user's one, but in that way sometimes email goes in spams.
We would like to change it to have a generic send contact#domain.fr, seems we can't handle it in Back-office.
So I tried to override the module to change the sender email.
The module was in modules/mod_je_quickcontact and there there is files mod_je_quickcontact.php, index.html, mod_je_quickcontact.xml and folder CSS, JavaScript, PHP, images
In my template I created a folder mod_je_quickcontact and I put there all thoses elements, and I changed the file mod_je_quickcontact.php
But it's not working, it's still default data which are displayed.
I looked at Internet to see how to override, but for all example I found, in default module there is tmpl/default.php file to override. I don't have such folder and file.
Maybe I missed something or I did it wrong... I don't know what to do know, so, if someone has an idea, it would be great!
I think in Joomla there is only a way to override a template or layout of modules. The module you used is not best practice, because there are not using a default template (tmpl/default.php) to display the output of the module.
Like in Joomla docs mentioned:
The directory structure you need is: TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php
(Source: Joomla override documentation)
What I would do: Copy the module, change it in the way you need it. That´s it.
There have to be a difference between paid and free modules :-P

magento 2 custom phtml page

Having just got myself acquainted (enough) with Magento 1.9, and able to make the customisations required, I've been told that once it's out, we're moving to Magento v2.0.
Having found the differences in the file structure, I believe I can see where to place my code for the custom pages we use, but how can I add this page from my project to a static block for later use?
Previously, the method used was as follows (I realise this may not follow the best practise, but it worked):
Create element folder within theme or core templates directory.
eg. /app/design/frontend/<theme>/default/template/myelement/mypage.phtml
Add this page/element to a static block using the following in the content editor:
{{block type="<theme>/default" template="myelement/mypage.phtml"}}
This block can then be added to the category pages as required.
In Magento 2, I have tried what I believe to be required, which is replicating the file structure and adding phtml files to this, so the template file now resides in:
/app/code/<supplier>/<module>/view/frontend/templates/mypage.phtml
Adding to the content editor the following:
{{block type="<supplier>/<module>" template="mypage.phtml"}}
Unfortunately, this does not display the intended page (element). It doesn't display the calling "{{block" entry either, which usually happens when the line is invalid, so I can only assume that I'm missing something with the link to this template.
If anyone can offer some assistance with this, I would be most grateful.
EDIT:
Continued research on this has led me to the following assumptions:
Magento 2 requires more than just a new .phtml page, even for simple customizations.
I'm still missing something.....
Having gone through 3 different tutorials on creating new modules for Magento 2, each providing slightly different methods, but fundamentally being the same thing, I now have what I believe should be all the code elements to make a new .phtml template for display in a static block.
This has led to an additional problem though.
While I have the required code, I cannot add the module. Adding the module to etc/config.php, as suggested in 2 out of the 3 tutorials, simply crashed M2, both admin and frontend when you try to clear the cache. This is the case after manually clearing cache folders in the var directory.
Also, still unable to add the .phtml template file to a static block or page using content editor.
Not much hair left to pull out here, so looking for help! Thanks in advance
There are a few samples on GitHub, including https://github.com/magento/magento2-samples/tree/master/sample-module-newpage which shows a module adding a new page with a very simple PHTML template file. This example does not use CMS content editing however - it is a sample based on using layout files.
You mentioned you were getting crashes. Would need more details to help on that one. If you got it solved, could you update this question and accept a response to close it out? Thx!
You Should try "class" instead of "type". So your code should look like.
{{block class="<package>\<module>\Block\MyBlock" template="mypage.phtml"}}
You Should try "VenderName_Modulename::myelement/mypage.phtml" instead of "myelement/mypage.phtml". So your code should look like.
{{block class="VenderNameModulename\Block\MyBlock" template="VenderName_Modulename::myelement/mypage.phtml"}}

Create custom module, with javascript and load javascript into footer

I have been assigned to create joomla template from HTML template, and this is first time for me. In HTML template I have a custom JS, and as far I can tell, I will need to create one, or maybe two custom modules in order to recreate functionality that exists. Is there some way to write JS for specific module and load it in footer (this module will be active only on one page, so I don't want to load JS on all pages). Is it possible to do this, or the simplest way is to load JS on everypage?
Please read the Joomla documentation on creating modules Creating a simple module and then on your module file mod_mymodule.php add the script call using:
$doc = JFactory::getDocument();
$doc->addScript( JUri::root() . "media/your_js_directory/your_script.js" );
Hope it helps.

Edit joomla template according to my design template

I just want to know can I customized joomla template to looks like my design template ? I already designed a template for customer. But he needs to develop his website using joomla. So I have to put my template to the joomla. is that possible ? if it is please send me some reference. I'm going thought with references.
Joomla templates are based around a PHP index file and allow you to create overrides for each of the content types output by Joomla.
The Joomla Doc's site has a section on templates that you should start with.
Make sure you read up on Template Overrides and Module Chrome as well. Reviewing the templates installed by Joomla is also a good place to start. You can get a good feel for how they are structured and what they're capable of by looking at the default templates.
By the way if your client is only just building their website now they should be starting with Joomla 3.2 not 2.5, it has a lot of great features and is very Bootstrap friendly. In fact the tag line for the 3 series is "Mobile Ready"
Template systems like JooStrap also have Bootstrap 3 integrated already.
I just want to know can I customized joomla template to looks like my
design template ?
That's tedious works; the opposite is easier. Your design can be turned to Joomla template. Just add template codes to your HTML and your design can be used as Joomla template.
For example, you need to add the following code before <html>:
<?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
For a basic guide, visit: https://docs.joomla.org/Creating_a_basic_Joomla!_template
There are also codes to display your website contents and modules.

Properly override a admin template file in Magento

I want to properly override this admin template file app/design/adminhtml/default/default/template/sales/order/create/form/address.phtml
From what I have found, the proper way is to create a layout file in a new module, set template path inside my module directory and reference that template file using reference node. But I have no clue how to do that.
I don't understand how the layout is controlled using xml as of now. Can someone show how to actually do that?
You should really create your own module, which you can then create a new template.
If you want to force is you need setTemplate() which takes your phtml path as a param. $this->getLayout()->createBlock('my_module/blockname')->setTemplate('my_module/template.phtml');
Bear in mind that the two slash notations here are different.
createBlock() is for a block, so will be in /app/code/<codePool>/My/Module/Blocks/<blockname.php>
setTemplate() is for the template, so will be in /app/design/<area>/default/default/template/template.phtml
Your <area> will be /adminhtml as you're in the admin backend.
In order to get the template working you'll need to create a new module and extend the adminhtml block file which uses this template. You'll have to find the block from the layout.xml and then you can extend the Block and specify a new template.
That's how I'd go about it, but I'm also really finding it hard to override things in the Adminhtml module.

Resources