How to point at the templates folder of a module in Drupal 7 - drupal

How do you make Drupal read the templates you create or override in a module (when you create templates that get overriden in the theme folder, Drupal reads them automatically)?

When you implement hook_theme() or hook_theme_registry_alter() (in the case you are overriding a template file defined from another module), you use the "path" property to tell Drupal where the template file is.
This is particularly important with hook_theme_registry_alter(), since you are overriding the template file used by another module, and you want Drupal looks for the template file in your module's directory. With hook_theme(), it is important to use the "path" property when the template file is not in the directory containing the module (or the theme), but in another directory, for example in a sub-directory of the directory containing the module/theme.

Related

Ghost CMS Custom Page assets route

I'm trying to create custom page in Ghost. I named file "news.hbs" for listing all the news items. Also I use webpack. Why while creating new custom page in template all the routes are matching as "news/*"? For example, while webpack generates "news.hbs" file, Ghost requires not an original path "img/header-bg.png", but an "news/img/header-bg.png". How to handle that? In main file "index.hbs" all the paths are valid, without extra folder's names.
You should modify the routes.yaml file for the routes to start working. Look at this documentation for more info: https://ghost.org/docs/api/v3/handlebars-themes/routing/

Typo3 extension configuration

I have installed typo3 extension "cookieman". The documentation says it comes with 2 static templates. Include the static TypoScript “Cookieman” in your root template or reference the necessary files in your site package. what is the location of a root template? and what is the syntax to include something?
first: be clear what Template means in this context.
there are multiple kinds of template in TYPO3.
There are HTML-templates which define the structure of parts of the output. That could be Fluid-templates or the older marker-based templates.
Then there are records which contain the typoscript configuration which also are called templates.
This typoscript-templates are meant. As the typoscript templates can be stored in each page of your page tree, which are concatenated, you have a root-template propably in the root-page of your website. (the added ts-template are called extension-templatesas they extend the basic configuration).
These records have a field for additional templates from TYPO3 extensions which are called static templates as they come from an extension and are never changed (never change any file from an extension inside the extension folders!!! you always can override the values).
Otherwise you can use explicit include statements in a typoscript configuration. The include statement was invented in TYPO3 4.6 and has changed it's syntax slightly until now. In the online-manual you can select your version to see syntax of your TYPO3 version.

Silverstripe v4 MVC Directories?

I'm Wondering Why There is no "Models / Views / Controllers" Directories Inside SS4 Main Directory? It's Seems Like Everything Should Go Inside "mysite/code" .. How To Accomplish MVC Style?
MVC is more of a software-architectural pattern, not how you organize files. There are only a few assumptions the SilverStripe framework makes on how you should organize your code:
Model
With SilverStripe 4, the default code folder for every module is named src or code. In that folder you're free to organize your files as you see fit. Ideally you build your folder structure in a PSR-4 compliant way, so that your folder-names match with your namespaces.
Controllers
Same as with Model classes, you can put your controllers anywhere you want.
There's a default assumption for Page classes though. These expect that the matching controller has the same namespace as the page. So if your page is named: Company\Module\Pages\MyPage, the framework would look for Company\Module\Pages\MyPageController.
You're free to override that though, by implementing the getControllerName method on your Page and return the FQCN for the controller to use.
Views
Also known as "templates" should be in a templates folder. Each module (your mysite folder is also a module) can have a templates folder.
In addition to this, you can have themes. Themes usually bundle templates, css and other assets. In the themes folder you can have multiple theme folders, each one can have a templates folder.

Plugin won't be translated

I've installed a calendar plugin (called Calendar, by Kieran O'Shea) and I'm having trouble with the translation.
In the plugin folder (which doesn't have any sub folders) there's a file called calendar.pot which I've translated with poEdit. What I've tried is to edit the file and save it (i.e. not create a .po and .mo file), create a .po and .mo file (e.g. calenderar.po) and put in the root and I've even tried to create a folder called language and put the files in there.
Nothing works.
What am I doing wrong?
Supposing WPLANG is defined as pt_BR, the plugin and theme translations should have it appended to the .mo/.po files.
Copy the calendar.pot to calendar-pt_BR.po, open in PoEdit, translate and save. It will generate the .mo on save.

Drupal6: I need to customize file upload links in node edit form

I am customizing the node/add and node/edit forms of a content type with a form_alter. In my content type, there is a file field that permits to upload files to the content.
What I would like to do is to customize the file box by changing the link to the file that is composed at runtime with Ajax. How can I do it without modifying Drupal core?
Your Private Files directory should not be in the docroot. Hiding it with a .htaccess rule will not work, as you point out in a comment.
Say you have Drupal in /var/www/sites/example.com/, then you should not store your private files under that directory; /var/www/sites/example.com/sites/default/private/files/ is just plain wrong.
You should, instead store the files where apache will not serve them, but can read them. E.g. in /var/www/files/example.com/. Then change the setting in Drupal to use that absolute path.
If you are running a large(r) site, you will probably want to store your files on a dedicated mount (drive, NFS etc.), say /media/nfs-example-com/.
Try Filefield Paths:
The FileField Paths module extends the default functionality of Drupals core Upload module, the FileField module and many other File Upload modules by adding the ability to use node tokens in destination paths and filenames.
http://drupal.org/project/filefield_paths

Resources