Adding an image from within a child theme on Moodle 3.11 - image

So, I'm new to Moodle and I'm creating a custom theme (child theme of Boost).
I'm a attempting to insert an image from the pix directory into the footer template - however I can't seem to get it to output any paths.
I've tried following the Moodle Docs - creating a directory mytheme/layout/footer.php and adding:
$templatecontext = [
'imageone' => $OUTPUT->image_url('mylogo', 'theme'),
];
echo $OUTPUT->render_from_template('theme_mytheme/footer', $templatecontext);
then including the following in my mytheme/templates/theme_boost/footer.mustache:
<img src="{{{imageone}}}" alt="Please give your image alt text or set the role to presentation" width="50" height="50">
However, all I get is the alt text and blank src.
I assume I'm doing something silly - but I'm not familiar enough with the Moodle context/output/renderers etc. to troubleshoot much further than I already have. And the documentation is not the greatest!
Thanks for any pointers!

You are reading theme_mytheme/footer mustache and you have changed theme_boost/footer.mustache (overrided in your theme nonetheless).
CHange
echo $OUTPUT->render_from_template('theme_mytheme/footer', $templatecontext);
to
echo $OUTPUT->render_from_template('theme_boost/footer', $templatecontext);
and then you can keep your example of mustache template

Related

How to provide details/summary HTML element in TYPO3's CKEditor?

Unfortunately there's no details/summary element in the default CKEditor configuration of TYPO3 and I'm looking for a way to add it.
What I've been trying to do:
I searched and found a widget on https://ckeditor.com/cke4/addon/detail , but it's repository on GitHub has been archived and the widget does not work as expected. It requires 'api,widget' and this generates a JavaScript error:
[CKEDITOR.resourceManager.load] Resource name "api" was not found at "/typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/Contrib/plugins/api/plugin.js?t=K24B-4e13cc129f".
When removing this requirement for "api", there's an error regarding line 72
CKEDITOR.api.parser.add(item, el);.
Then I found a similar widget at GitHub , which looks like an older version of the former without requirement for "api".
It already looks quite good, but is still a bit buggy: the HTML structure is changed when saving and the summary is duplicated. When switching to the source code, the HTML structure specified in the template ...
<details><summary>Summary</summary><div class="details-content"></div></details>
… get's partially lost.
I'm not sure if the widgets are buggy or if the editor is limited by the integration into TYPO3 and I was also not able to combine the two in a way that would lead to a working solution.
Update (Jul 22):
I successfully modified the Creating a Simple CKEditor Widget (Part 1) example to create
a widget with the following HTML structure:
<div class="expander">
<p class="expander-title">Title</p>
<div class="expander-content"><p>Content...</p></div>
</div>
With the help of a small JavaScript snippet and some CSS it now behaves almost like a details-summary element, but is not quite as good in terms of SEO and accessibility.
If I replace the elements <div class="expander"> and <p class="expander-title"> with <details> and <summary> in the widget, it unfortunately doesn't work properly anymore and changes the structure when saving. For some reason the RTE treats them differently.
I have already manually added the following to the RTE configuration:
processing:
allowTags:
- details
- summary
allowTagsOutside:
- details
- summary

How To Emit Only Gallery IMGs from Batflat CMS

If you make a Gallery in Batflat CMS, the template tag it creates will generate its only Bootstrap HTML for a gallery. What if I just want to emit IMG tags for the gallery items, instead?
Create a Gallerymod custom module. That way, your customization may likely survive a Batflat Update.
Copy inc/modules/galleries as inc/modules/gallerymod.
Remove the lang folder and Admin.php in your gallerymod folder.
Change the Name and Description inside the gallerymod/Info.php, as well as the comments. I used static strings instead of code. Also in this file, inside the install function and uninstall function, remove code inside those so that it does nothing on install or uninstall.
In your gallerymod/Site.php, look for the $assign[$gallery['slug']] assignment, and on the following line, add:
$assign[$gallery['slug'] . '-alt1'] = $this->draw('gallery-alt1.html', ['gallery' => $tempAssign]);
Also, where you have the namespace line set as namespace Inc\Modules\Galleries;, change it to namespace Inc\Modules\Gallerymod;.
In your gallerymod/view folder, create a gallery-alt1.html file and add these contents:
{loop: $gallery.items}
<img class="photo-{if: $value.title}{$value.title}{/if}" alt="" class="img-responsive" src="{?=url($value.src.lg)?}">
{/loop}
Now activate this inactive module in Batflat's admin system. You'll notice that it has no admin panel -- because it doesn't need one. You already have the Galleries one. Do not deactivate the Galleries module because the Gallerymod module relies on the Galleries module.
Now, from your custom theme template, you can call this by varying how you called the old slug. So, if your old way of calling the gallery was something like {$gallery.home-photos}, then you would merely tack on the "-alt1" on the end and call it like {$gallery.home-photos-alt1}. I like to wrap these in a DIV wrapper with an ID on it so that I can address it with CSS, jQuery, or Javascript.
In the Batflat Admin system, go back and edit your image titles in the gallery. Treat those titles like a slug (lowercase alphanumeric phrase with dashes) because these are used as class names on the IMG tags in gallery-alt1.html, and you may want to address these individually in CSS, jQuery, or Javascript, later on.
Refresh your browser and you may see the source code display something similar to:
<div id="hidden-images" class="hidden">
<img class="photo-man2" alt="" class="img-responsive" src="https://example.com/uploads/galleries/2/15831273220.jpg">
<img class="photo-woman1" alt="" class="img-responsive" src="https://example.com/uploads/galleries/2/15831272980.jpg">
<img class="photo-man1" alt="" class="img-responsive" src="https://example.com/uploads/galleries/2/15831272540.jpg">
</div><!-- hidden-images -->
Just remember that if you update your version of Batflat, that you may need to reapply this customization again -- it depends on what was done in the update to the existing Galleries module.
If you have different tastes as to how you want to format your images, just edit your gallery-alt1.html file. Plus, you can make multiples of these for different situations, such as gallery-alt2.html, gallery-alt3.html, etc. You can even make it emit JSON instead of html so that you can insert it into a Javascript block in your theme.
Another tip for debugging, in case your site won't load or the admin system breaks, is to edit inc/core/defines.php and change the DEV_MODE to false. That way, PHP will show you every error and that might help you in debugging what might be wrong.

I can't find the proper css in joomla

I need to modify the width of each column in a 2 column custom theme and can't find the place to do this. I tried using firebug but no luck. I looked over the main joomla css (didn't quite expect it to be there), and the theme template.css.
I'm sure veteran joomla programmers have ran into this plenty of times and this is an easy solve for them :P
I just need to know the places to look.
Thanks.
If you're using firebug and you still can't find the path to the css file, may be you have some kind of plugin or template that packs all your style sheets into a single file?
If so, you should disable it, clear your cache, then try again with firebug, and once you find where is the css file located, enable the plugin / template feature again.
If you still can't find it, can you post the url here to take a look?
I hope it helped!
Maybe there's no css for this.
Sometimes the width of columns in articles is inside de template itself like this:
<td valign="top" width="<?php echo intval(100 / $this->params->get('num_columns')) ?>%" class="article_column<?php echo $divider ?>">
<?php for ($y = 0; $y < ($this->params->get('num_intro_articles') / $this->params->get('num_columns')); $y ++) :
if ($i < $this->total && $i < ($numIntroArticles)) :
$this->item =& $this->getItem($i, $this->params);
echo $this->loadTemplate('item');
$i ++;
endif;
endfor; ?>
</td>
To find something like this code look into:
template folder/ content/ com_content / the view you want to edit (i.e. : section view, category view etc)...
Also if you use Firebug or Webkit Inspector you should see the inline style as a result of this code.
If you use firebug, you should definitely see the path of the particular css. Just right-click on some column -> click on inspect element and then you see the css path on the right-hand side.
If your column styles are set inline, you will have to modify the right template for this. Its probably your index.php in your themes root folder or some template in the html folder.

How to add an additional article info on sidebar in Joomla 1.5?

I want a sidebar on article page, with additional info. Is there such a solution for Joomla 1.5.
I mean that I add an article and the info is pulled from my text between the tags e.g.
{info_for-sidebar}
Lorem ipsum....
{/info_for-sidebar}
And this info shows in sidebar for current article with actual info.
Is this possible?
Setting up something like what you are asking for require some sort of workarounds.
First, lets agree that what you are calling a "sidebar" is nothing but a content... You enter that content as a part of your article.
So, to achieve what you are asking for I would recommend you use what is called CCK - Content Construction Kit - extension for Joomla using Form2Content. There's a free light edition that would be enough.
Form2Content let you setup a content type. You define what fields you want for each content. Then you create a template that will use the info you are going to enter on the fields to built an article layout.
So let's say you are going to create 3 fields like this :
1- Intro text
2- Full text
3- Sidebar
You are going to create a template as we said. each content type will have 2 templates an intro text template and a full text template
The full text template shall be like this :
<div class="content-container">
<div class="content-sidebar">{$SIDEBAR}</div>
<div class="content-fulltext">{$FULLTEXT}</div>
<br clear="both" />
</div>
The {$SIDEBAR} and {$FULLTEXT} are the text you entered in the form and Form2Content will use it to create a regular content with layout.
If you don't want to use another extension or that solution looks too complicated, you could use a javascript solution. For example you could create an HTML module in Joomla and assign its to the sidebar. On this module switch the view to HTML code and enter this:
<div class="content-sidebar"></div>
When you enter an article, switch the view to HTML code and enter the text you want to show on the sidebar and add a class to the paragraph or the div like this :
<p class="special-content">Lorem ipsum dolor<p>
Then use jQuery to append this special text to the sidebar like this :
jQuery(".content-sidebar").append(".special-content");
Note: Joomla does not load jQuery by default, you have to add it on your template or use a plugin.

Where does VM derive code for $file_list?

Can someone tell me where the code for $file_list is sourced in Virtuemart? To be specific, in the flypage.tpl.php file, there is a snippet of code that looks like this:
<span style="font-style: italic;">
<?php echo $file_list ?>
</span>
This code generates the HTML for files that have been linked to the product. Unfortunately, the formatting of that section is pretty ugly by default and I'm trying to figure out how to modify the source. Can't find it to save my soul. It doesn't appear to be anywhere in the template files.
it should be here:
administrator/com_virtuemart\classes\ps_product_files.php
and search for function get_file_list
Right under this function (row 622 - 626) should be html template for product files.
Also hate this non MVC architecture. Looking forward to VM 2.0

Resources