Alfresco custom aikau footer - dojo

I want to customize Alfresco aikau footer. For the beginning I would like to inject custom html-template in AlfShareFooter. So far I created an extension:
<extension>
<modules>
<module>
<id>MyCmpny widgets</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<configurations>
<config evaluator="string-compare" condition="WebFramework" replace="false">
<web-framework>
<dojo-pages>
<packages>
<package name="mycmpny" location="js/mycmpny"/>
</packages>
</dojo-pages>
</web-framework>
</config>
</configurations>
</module>
</modules>
</extension>
Html template for the footer and now I'm trying to override templateString of the AlfShareFooter object:
define(["dojo/_base/declare",
"alfresco/footer/AlfShareFooter'",
"dojo/text!./templates/ep-footer.html"],
function (declare, AlfShareFooter, template) {
return declare([AlfShareFooter], {
templateString: template
})
});
But it doesn't work. I am not familiar with Dojo and I think the problem is in the syntax...

I've found out how to override template:
define(["dojo/_base/declare",
"dojo/text!./templates/my-footer.html",
"alfresco/footer/AlfShareFooter"],
function (declare, template, AlfShareFooter) {
return declare([AlfShareFooter],{
postMixInProperties: function my_footer_AlfShareFooter__postMixInProperties(){
this.inherited(arguments);
this.templateString = template;
}
});
});
But with g̶r̶e̶a̶t̶ custom footer template comes g̶r̶e̶a̶t̶ custom css and i18n... So I wrote a post about changing Aikau footer in Alfresco.

Related

Shopware - Not able to show my page in My apps

I created Shopware App. I wanted to show my app in Iframe. But always showing "Whoops! You’ve moved too fast and lost orientation."
This is my manifest.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/platform/trunk/src/Core/Framework/App/Manifest/Schema/manifest-1.0.xsd">
<meta>
<name>TF</name>
<label>TF</label>
<label lang="de-DE">TF</label>
<author>TF</author>
<copyright></copyright>
<version>1.0.0</version>
<license>MIT</license>
</meta>
<setup>
<secret>test</secret>
<registrationUrl>https://example.com/shopware/register</registrationUrl>
</setup>
<permissions>
<read>order</read>
<read>product</read>
</permissions>
<admin>
<main-module source="https://example.com/app/shopware"/>
</admin>
</manifest>
I am using Laravel for my site. And I created route like
Route::get('/app/shopware', 'ShopwareController#showApp');
and my function is
public function showApp(Request $request)
{
echo 'Showing TF';
}
If I access this URL directly its working fine, but in Shopware showing error like this
How to solve this issue?
Thanks
I think you need to append the shop id and a timestamp to the url in the registrationUrl tags. This could be the reason shopware throws this error.
Take a look in here App Base Guide
There is an example of how a request should look like.
I think you need to add script code in the response html
<script>
window.onload = function () {
window.parent.postMessage('sw-app-loaded', '*');
}
</script>

Hide developer tool for non-administrator

I want to hide the Open Developer Tools button for non-administrators.
When I search the solution on the internet, I find the module to hide that button, but I have to pay about $50. Is there a solution to achieve those things without having to pay?
I have already deactivated developer mode. But the weird thing is, the Open Developer Tools button is hidden for admin, but is shown for non-admin.
You can alter the WebClient.DebugManager template to add a condition on the menu item.
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-extend="WebClient.DebugManager">
<t t-jquery="li" t-operation="attributes">
<attribute name="t-if">widget.is_admin</attribute>
</t>
</t>
</templates>
Then extend the web.DebugManager widget to set the value of is_admin:
odoo.define('MODULE_NAME.DebugManager', function(require) {
'use strict';
var DebugManager = require('web.DebugManager');
var session = require('web.session');
DebugManager.include({
init: function () {
this._super.apply(this, arguments);
this.is_admin = session.is_system;
},
});
});
You can check how to add a file in an asset bundle and how to extend templates in Odoo documentation.

Custom widget js doesn't recognize template from qweb

I try to test custom widget from js reference and I get error in debugger:
Error: QWeb2: Template 'some.template' not found
qweb.xml was properly set in manifest, because when I extend ListController and use another template, it works correctly.
Here is template definition, which I use in qweb.xml:
<?xml version="1.0" encoding="UTF-8"?>
<template>
<div t-name="some.template">
<span class="val"><t t-esc="widget.count"/></span>
<button>Increment</button>
</div>
</template>
I tried to change <template> -> <templates>, totally removed tag "template" but still get the same error message.
JS:
odoo.define('working.test', function (require) {
var Widget = require('web.Widget');
var Counter = Widget.extend({
template: 'some.template',
events: {
'click button': '_onClick',
},
init: function (parent, value) {
this._super(parent);
this.count = value;
},
_onClick: function () {
this.count++;
this.$('.val').text(this.count);
},
});
// Create the instance
var counter = new Counter(this, 4);
// Render and insert into DOM
counter.appendTo(".o_nocontent_help");
})
Manifest:
# -*- coding: utf-8 -*-
{
'name': "testwidget",
'summary': """
Short (1 phrase/line) summary of the module's purpose, used as
subtitle on modules listing or apps.openerp.com""",
'description': """
Long description of module's purpose
""",
'author': "My Company",
'website': "http://www.yourcompany.com",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/12.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
'category': 'Uncategorized',
'version': '0.1',
# any module necessary for this one to work correctly
'depends': ['base'],
'qweb': ['static/qweb.xml'],
# always loaded
'data': [
# 'security/ir.model.access.csv',
'views/views.xml',
'views/web_asset.xml',
],
# only loaded in demonstration mode
'demo': [
'demo/demo.xml',
],
}
Any idea how I need to modify this template to make the widget working correctly and in which table in db odoo stores these templates?
I was running into this same issue and needed to put my QWeb code into static/src/xml/base.xml in order for Odoo to recognize it.
You can check to see if Odoo is loading the QWeb by going to this URL on your Odoo instance:
<odoo_instance>/web/webclient/qweb?mods=<my_module_name>
Such as:
localhost:8069/web/webclient/qweb?mods=test
For comparison, you can see a successful output by using mods=web to load the QWeb assets for the web module.
You can try changing
'qweb': ['static/qweb.xml'],
to
'qweb': ['static/*.xml'],
It happens with me sometimes, by specifying static xml file name, it does not render that template. But by just loading all .xml files by using *, templates are loaded.
To solve this issue I used as workaround Widget.xmlDependencies:
xmlDependencies: ['/test/static/qweb.xml']
but the main reason I think was cache in PyCharm which I didn't invalidate.
After having done some code reading, IMO, I realized the official documentation might not have pointed out clearly how to use templates in frontend.
To summarize my understanding:
The 'qweb' field in manifest is mainly designed for webclient (i.e. the backoffice), not the website. When entering webclient, a request to /web/webclient/qweb is made to retrieve all the templates of installed modules.
In order to use templates in website (i.e. frontend), synchronous and asynchronous ways both exist.
Synchronous way: Use qweb.add_template. When parameter is template content itself or a DOM node, template is loaded in a synchronous way. (While param is a URL, then it fires up an ajax request to server to fetch content.)
qweb.add_template is mentioned in https://www.odoo.com/documentation/13.0/reference/qweb.html
Asynchronous way:
Use ajax.loadXML which you can use anywhere you want to start loading template from a URL.
Use xmlDependencies which you specify in widget definition. And if you dig into the code in widget.js, you can see ajax.loadXML is being used in willStart.
There are discussions regarding qweb.add_template vs ajax.loadXML
See https://github.com/OCA/pylint-odoo/issues/186 and https://github.com/odoo/odoo/issues/20821
FYI.
I guess you may need to make sure that the js definition refers to the module name correctly
odoo.define('MODULE TECHNICAL NAME SHOULD BE HERE.test', function (require) {});
you should also register your js function with something like:
core.action_registry.add("module_name.name", Widget_Extend);
for more info https://www.odoo.com/documentation/11.0/reference/javascript_reference.html#registries
In Odoo 14 make sure
dashboard.js
odoo.define('library_managment.dashboard', function(require) {
"use strict";
// alert("hello odoo...............")
console.log("Hello My Module........!!")
var widgetRegistry = require('web.widget_registry');
var Widget = require('web.Widget');
var Counter = Widget.extend({
template: 'library_managment.template',
xmlDependencies: ['/library_managment/static/src/xml/template.xml'],
events: {
'click button': '_onClick',
},
init: function (parent, value) {
this._super(parent);
this.count = 4*9+5;
console.log("parent is", parent)
console.log("counter is..", this.count)
},
_onClick: function () {
this.count++;
this.$('.val').text(this.count);
},
});
widgetRegistry.add('library_counter', Counter);
return Counter;
});
template.xml
add this
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<div t-name="library_managment.template">
<span class="val">
<t t-esc="widget.count"/>
</span>
<button class="bg-danger">Increment</button>
</div>
</odoo>
then add js file in assets.xml inside youe views
<odoo>
<template id="assets_backend" name="Library assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/library_managment/static/src/js/dashboard.js"></script>
</xpath>
</template>
</odoo>
then add in manifest like this:
'js': ['/static/src/js/dashboard.js'],
'qweb': ['/static/src/xml/template.xml']
then inside form view add this line
<widget="library_counter"/>
I had the same problem but with "hr_org_chart" template idk why everything works fine in another computer but in mine it returned this problem, I solved it by installing this module hr-org-chart

Global function works in preview but fails when code is run

I have a global function named 'finalPrice' which is defined in my configuration.xml file.
The function takes in a value - does stuff to it - and returns the final value. I reference the function from within DataWeave. When I click 'preview' I can see the correct output in the preview window. However when I run it I get the error:
Message : Exception while executing:
There is no variable named 'finalPrice'.
I have run the code on my local machine and in CloudHub and I get the same result
XML Code:
<configuration doc:name="Configuration">
<expression-language>
<global-functions>
<!-- This function is called by the 'Validate and Transform' dataweave component in the 'main' flow-->
def finalPrice(incoming_value)
{
import java.lang.String;
import java.math.RoundingMode;
// Do Stuff
return strFinalNumber;
}
</global-functions>
</expression-language>
</configuration>
DataWeave Code:
//Refer to "finalPrice" Global Function in the main.xml configuration file
DB_FINL_PRCE: "field_missing" when payload01.DB_FINL_PRCE == "" otherwise finalPrice(payload01.DB_FINL_PRCE)
Any help appreciated
It's an issue with the comments in the global-functions. So remove or modify the line:
<!-- This function is called by the 'Validate and Transform' dataweave component in the 'main' flow-->
and just have:
<configuration doc:name="Configuration">
<expression-language>
<global-functions>
def finalPrice(incoming_value)
{
import java.lang.String;
import java.math.RoundingMode;
// Do Stuff
return strFinalNumber;
}
</global-functions>
</expression-language>
</configuration>
Or modify your comments to //
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<global-functions>
//This function is called by the 'Validate and Transform' dataweave component in the 'main' flow
def finalPrice(incoming_value)
{
// Do Stuff
return "somethingelse";
}
</global-functions>
</expression-language>
</configuration>

How do I write html to magento footer in a module

I am trying to make a basic Magento module that writes to the footer of a store.
Here's what I've got so far.
<?php
class CTRL_DRP_Block_Footer_Footer extends Mage_Page_Block_Html_Footer{
protected function _toHtml(){
$html = 'CPTEST';
return $html;
}
}
I'm not sure if I'm heading in the right direction here. Can someone send me resources to help me learn how to go about this correctly?
Any help is appreciated.
The footer block already exists so you only need to add a simple block inside it.
In your module's config.xml file define a layout file.
...
<frontend>
<layout>
<updates>
<YOUR_MODULE>
<file>YOURMODULE.xml</file>
</YOUR_MODULE>
</updates>
</layout>
</frontend>
...
In the base theme's layout/YOURMODULE.xml file add to the footer block.
...
<default>
<reference name="footer">
<block type="core/template" name="YOUR_MODULE_footer" template="YOURMODULE/footer.phtml" />
</reference>
</default>
...
Create the appropriate template/YOURMODULE/footer.phtml file for the same theme.
<p>CPTEST</p>