how Joomla back-end's core works? - php

In the Joomla back-end, the administrator would do modifications using the GUI.
Say a module is enabled(just click the check box).
What happens in php-level?(what happens to the code?)
Some trivial assumptions I come up with are,
-commenting/uncommenting
-some code snippets are added/removed
-configuration(ex: xml) files are modified/created

Joomla itself doesn't really modify files on disk much at all. The only exceptions I can think of are:
Installing an extension (writes to '/tmp', and then the final location for the extension files)
Saving global configuration options (writes to '/configuration.php')
Caching (writes to '/cache')
All other configuration changes, entered data, etc from the admin area (and frontend) are stored in the Joomla database.
So the example given (enabling/disabling a module) doesn't edit or create any files. It only makes changes in a core database table (jos_modules, if your DB prefix is 'jos_'). Module inclusion on all pages is dynamically evaluated per page-load based on the code in your template, as #Hanny mentions.

If you read the index.php file in of the template you're using - you'll find that all the positions of the template are included in that file <jdoc include="position10" /> or something of that nature is what it will say.
Usually the templates use CSS to help determine how to 'shape' the page depending on which modules are enabled, along with 'if,then,else' statements on the php level. Read through the index.php file and you'll probably see that.
if "module10" then use "rightmodule.css" type thing - which then may hold changes to be made to certain containing div's with regards to width and that sort of thing.
No commenting/uncommenting happens, no code snippets are added and no configuration files are modified/created (at least as far as I know, and I've worked to design a component for Joomla previously). It's all if statements and tying that together with the module positions that are laid out in the templates index.php file.
This is a simplified answer, but I think it answers what you've asked.

Related

php files inclusion structure in Joomla?

I am currently experimenting with Joomla (3.7) templating system for my company. I am not new in php and inclusion, but a beginner with Joomla.
I have been searching through the web and i haven't found any clear structure schema for the file inclusion in Joomla, something like what we can find here for wordpress for example: https://codex.wordpress.org/File:Template_Hierarchy_2015.png
For example, i stumbled upon this: while experimenting with template creation, i wanted to store a value that could be used in a layout, testing setUserState function. The layout i tested was the one used to render custom fields (which are new in 3.7). The result is that it seems that fields/render.php is actually executed before template's index.php (the value is only available after page reload when set in index.php, whereas it is immediate when set in render.php).
Did someone saw a clear schema of this inclusion structure? It is not only for the said example, but mostly for a better understanding of the framework.. sorry if already asken or if too vague for the site.
edit - note about my example: collecting info bits by bits, it seems that the template file index.php is executed first and buffered so that it can be parsed for jdoc statements. Intuitively, because an article content is in this case imported by a jdoc (<jdoc:include type="component" />, the main content in the article page), the custom fields render.php should be called after index.php. Could it be the buffering part that prevents the user state to be set in time?

Drupal 7 Web Experience Toolkit - How to modify theme?

I have been going insane trying to figure out how to modify the WET-BOEW distribution of Drupal 7 and have been met with little to no results.
http://drupalwxt.github.io/
I do not have a lot of experience with drupal. I used it many years ago and I hated it as much then as I do now; unfortunately, employment requirements have forced me to dig into it again.
How do I go about modifying the theme? Even just modifying the header would be a massive step in the right direction.
For the record, the files I am modifying are in /profiles/wetkit/themes/wetkit_bootstrap/templates
Modifying system/page.tpl.php has no effect
Modifying system/html.tpl.php has an effect, unfortunately I am met with $page_top, etc and no actual markup for the header.
I am completely and utterly lost.
EDIT 1
I have created a folder under /sites/all/themes called "playground". In this file, I have added my basic info and copied the regions from the original wetkit info file.
I created the structure for <theme>/templates/system and added an html.tpl.php file containing a die() to test if it is overriding the base theme...it does not appear to be.
I make a point of clearing the cache after every change.
EDIT 2 (Solution)
It turns out that I was trying to modify the wrong file all along. For the WET-BOEW Drupal 7 distribution, changing the markup is done through <theme>/templates/panels/page--panels--wet-boew.tpl.php and by adding a custom CSS file to theme_name.info.
I'm sure this is all elementary stuff, but I've been struggling with it for a while now. Thanks for the help.
First, go to appearance page (url: /admin/appearance) and see what theme is used. Maybe you are changing wrong theme.
Then, check if page caching is on on performance page (/admin/config/development/performance). If so, you may need to clear the cache after every change with "Clear all caches" button on same page.
Oh and those system template files are usually overwritten with custom theme files. So don't change them.
Again, theme template files are usually placed in directory:
/sites/all/themes/theme_name/templates
starting from website root, so look for the files there or on some similar location if you have some specific site settings (multisite or something).

Datalife engine - where are the functions in .tpl files called from?

I'm migrating my blog from wordpress to datalife engine. For what i figured it out by searching, is writen in smarty php... I never worked with it before and i want to query the database to implement something on the theme... But i can't write it on the tpl files...
What i want to know is, where are functions like {rating}, {content} or [related-news] declared...
i want to query the database, but for what i know, i can't do it on the tpl files direcly.
And i can't find any info where they are because all the readme files of datalife are in russian. Can someone help me to figure out how is this structure done?
Datalife Engine use the module files in folder /engine/modules/ to define which .tpl files to use for which function, so there is no single file that declare all tpl files, you have to check which module or which function you want to edit, in your case it seems like you are looking for full page of content which in DLE called "fullstory" the module that handle this module is engine/modules/show.full.php and the theme file to use for this module are fullstory.tpl to dispaly the rest of fullstory, addcomment.tpl for add comment form and relatednews.tpl to display related news, about {rating} there are at least 3 modules use this tag which are show.short.php, show.custom.php and show.full.php, however the DLE structure is each module use its own tpl file to display as {content}, I think if you go to dlestarter.com you can get all answer you need from them, I think they are not so advanced team but they do speak English so they can help you more effectively to any questions you may have...good luck!
Datalife Engine does not use smarty template engine!.
It has it's on custom engine.
The Flow of the cms its simple, every article has a short story and optionally a full story.
In the template folder you have a bunch of tpl files with build up the final page.
main.tpl beeing the file called for every page you display.
Now typically once you call the front page the main.tpl along with shortstory.tpl are called along with other blocks for the front page.
the shortstory.tpl is build by the /engine/modules/show.short.php file witch will call the db for the data or memcached if enabled and the data was cached replace the the engin tags with the necessary data like {title} and many others.
You should really look at the documentation to undestand witch tags are found in witch section.
One important think to note is that you cannot add php in the tpl files at least not out of the box but you can include files with php in them.
I recommend heading over to dlestarter.com they are a good reference for documentation in English and pretty much the only once as well. They also have a forum where i look into sometimes.

How to trace where Magento is calling templates from?

I'm working with Magento. See the following code:
<?php echo $this->getChildHtml('topMenu') ?>
Is there an easy way to find where HTML resides. I.e. is there some kind of trace I can use?
In the admin go to System > Configuration > Developer, pick a store from the "Configuration Scope" select in the top left corner, then there will be a new option in "Debug" section called "Template Path Hints". Turn this on and refresh your store page again.
This and more is explained in the Designer's Guide to Magento.
I fully agree with the answer of clockworkgeek - the easiest way is to turn on Template Path Hints in System -> Configuration -> Developer section of admin panel (scope of your store must be chosen for this field to appear). After that all your store pages will be rendered with inclusions of red panels, showing the path to templates.
Nice addition is also to turn on Add Block Names to Hints in the mentioned above admin section - so you'll also see block names serving that templates.
These actions will allow you to easily trace 95% of all design.
However, there are also some blocks that do not render phtml. Or they overload standard toHtml() method in such a way that it doesn't show template's path. These are more complicated cases. To find the place where design is created you should either:
Learn layout-blocks-phtml model of View part in Magento - Designer's Guide to Magento is a good place to study it. Then you'll be able to find blocks and templates by layout structure.
Install X-Debug, set it up for your IDE, set a breakpoint at <?php echo $this->getChildHtml('topMenu') ?> line and dig in this line. It's the easiest and most universal way to solve your problem (although knowledge of Magento design structure still is a must).

How should I integrate some javascript into a php application?

I have a medium size legacy php application with almost no javascript integration. I've recently been learning javascript (yes actually learning it) using Douglas Crockfords excellent book and taken YUI as my library of choice. I've tried out a few things and got a few things working but now I want to integrate the various components etc into my application properly, my question is how to go about doing this for ease of maintenance and code reuse.
Currently the application consists of
php pages
smarty templates (html templates with some special template markup) for each section of a page so multiple templates may be used for a single page.
single css file.
I have the following ideas about how to integrate my javascript into the pages.
Write inline javascript in each smarty template with the code required for that section.
Write a seperate .js file to go with each smarty template that is linked in and then a single inline script to run it.
a seperate .js file for each php page which would have all the functionality required for the entire .php page. A small inline function would call whatever functions were required.
Something I havent though of?
Does this make any sense? Does anyone have a good suggestion for this?
Update:
One extra bit of info is that its an internal application, so its not so important to restrict everything to a single file.
Two other options:
A single JS file that contains all the JS for your entire site. Depending on your caching settings, you should be able to get the user to download just one file for the entire site and use a cached version for every other page.
Divide your JS up according to function, rather than page, and include whatever functionality each page requires. E.g. one page may require tabs, form validation and animation, while another may only require tabs.
Or you can have a hybrid of these: one JS file that contains the vast majority of your code and an extra file if needed for particular pages or templates.
None of the approaches mentioned are wrong (though I'd skip the inline JS one as much as possible); which one is best will depend on your precise situation and your personal preferences.
Firstly, most setups allow a master layout template in which you can place a common page opening or, alternatively, each template includes some global header.
That being said, you should do a combination of 1, 2 and 3:
Have a .js that is included in all templates that contains global functionality. Each template may also optionally have it's own .js specific to that page or section of pages. Finally, if there's tiny amounts of code specific to a page (or must be dynamically generated each time), it won't make sense to initiate another http connection for it so have that source be right in the template.
if you don't have a ton of javascript then create an external js file and include it in the header of the webpages and be done with it.

Categories