Automatic link in admin menu - admin

I've followed this small tutorial, and made what i needed:
Stackoverflow - Custom admin page
But now i needed to put a link to it in the admin menu, automaticly when I upload my files to the server...
How can I do it? :s googled for it, but I think I couldn't find the answer :s

This can't be done automatically when you upload the files to the server. You will need to create a vQmod to edit the admin header files to insert it

You should tell us what version of opencart you are using, do you have vqmod (do you intend to use it at all), and where would you like that page link to show up in admin panel.
You need to install vqmod (follow instructions)
create .xml file, save it to vqmod XML folder and put this in it
<modification>
<id>Add a link</id>
<version>1.5.4</version>
<vqmver>0.1</vqmver>
<author>Jeffrey Murdock</author>
<!-- edit header controller -->
<file name="admin/controller/common/header.php">
<!-- create link to your page -->
<operation error="log">
<search position="after"><![CDATA[$this->data['setting'] = $this->url->link('setting/store', 'token=' . $this->session->data['token'], 'SSL');]]></search>
<add><![CDATA[
$this->data['hello_world'] = $this->url->link('custom/helloworld', 'token=' . $this->session->data['token'], 'SSL');
]]></add>
</operation>
<!-- / -->
</file>
<!-- edit header template -->
<file name="admin/view/template/common/header.tpl">
<!-- add link to your page -->
<operation error="log">
<search position="before" offset="1"><![CDATA[<ul class="right">]]></search>
<add><![CDATA[
<li><a class="top">Your link</a>
<ul>
<li>Hello World</li>
</ul>
</li>
]]></add>
</operation>
<!-- / -->
</file>
</modification>
If you installed vqmod properly, and have opencart 1.5.4 version, this should display link in your administrator top menu.

Related

How to get user information to .tpl file in opencart using vqmod?

I am new in opencart and I am trying to make some changes using vqmod.I have built a xml file which will add some text on product_list.tpl depending on user's id.The problem is that I cannot get id.I tried a lot but still no success.If anyone knows how can I achieve this please post.I get this notice on browser -> Notice: Undefined property: Loader
Here is my xml file:
<modification>
<id>GeoDim - add message products depending on user login</id>
<version>1.0</version>
<vqmver>2.4.1</vqmver>
<author>GeoDim</author>
<file path="admin/view/template/catalog/product_list.tpl">
<operation>
<search position="after"><![CDATA[div class="pull-right"]]></search>
<add><![CDATA[
<?php
// GeoDim - add message products depending on user login
$this->load->model('user/user');
$user_group_id = $this->model_user_user->getUsersGroupId($this->user->getId());
if ($user_group_id == 1) {
echo '<p style="background-color: yellow;font-size: 21px;float: left;margin-right: 5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο TEST</p>';
}else {
echo '<p style="background-color: orange;font-size: 21px;float:left;margin-right:5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο LIVE</p>';
}
// END GeoDim - add message products depending on user login
?>
]]></add>
</operation>
</file>
</modification>
Which version of Opencart?
Since there's no getUsersGroupId function in model/user/user.php on opencart 2.x I used getUser here, I've tested this on opencart 2.1.0.1.
You must first get user_group_id in controller file and then send it to view file via $data, so edit this file:
admin/controller/catalog/product.php
Find getList function and add this inside it:
$this->load->model('user/user');
$user_group_id = $this->model_user_user->getUser($this->user->getId());
if ($user_group_id['user_group_id'] == 1) {
$data['paragraph'] = '<p style="background-color: yellow;font-size: 21px;float: left;margin-right: 5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο TEST</p>';
}else {
$data['paragraph'] = '<p style="background-color: orange;font-size: 21px;float:left;margin-right:5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο LIVE</p>';
}
and then in admin/view/template/catalog/product_list.tpl use it:
<?php echo $paragraph; ?>
Here is full code:
<modification>
<id>GeoDim - add message products depending on user login</id>
<version>1.0</version>
<vqmver>2.4.1</vqmver>
<author>GeoDim</author>
<file path="admin/controller/catalog/product.php">
<operation>
<search position="after"><![CDATA[$results = $this->model_catalog_product->getProducts($filter_data);]]></search>
<add><![CDATA[
// GeoDim - add message products depending on user login
$this->load->model('user/user');
$user_group_id = $this->model_user_user->getUser($this->user->getId());
if ($user_group_id['user_group_id'] == 1) {
$data['paragraph'] = '<p style="background-color: yellow;font-size: 21px;float: left;margin-right: 5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο TEST</p>';
}else {
$data['paragraph'] = '<p style="background-color: orange;font-size: 21px;float:left;margin-right:5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο LIVE</p>';
}
// END GeoDim - add message products depending on user login
]]></add>
</operation>
</file>
<file path="admin/view/template/catalog/product_list.tpl">
<operation>
<search position="after"><![CDATA[div class="pull-right"]]></search>
<add><![CDATA[
<?php echo $paragraph; ?>
]]></add>
</operation>
</file>
</modification>

Opencart - Test VQmod XML file - What's wrong here?

just getting used to using VQMod.
What is wrong here? It isn't updating on the front-end.
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>VQMOD CORE FOR OPENCART - DO NOT REMOVE</id>
<version>1.4.x and above</version>
<vqmver required="true">2.5.0</vqmver>
<author>vqmod.com</author>
<file name="admin/view/template/common/footer.tpl">
<operation info="Example of the vQmod">
<search position="replace"><![CDATA[
<?php echo $affiliate; ?>
]]></search>
<add><![CDATA[
I am replaced content!!
]]></add>
</operation>
</file>
</modification>
Cheers!
Actually you are trying to change the "backend" but with no luck!
I think you should read:
vQmod: https://github.com/vqmod/vqmod/wiki
Examples: https://github.com/vqmod/vqmod/wiki/Examples
Scripting: https://github.com/vqmod/vqmod/wiki/Scripting
The problem is the following, in this file footer.tpl
admin/view/template/common/footer.tpl
This is the content:
</div>
<div id="footer"><?php echo $text_footer; ?></div>
</body></html>
And your script want to find this "echo $affiliate;" but this content don't exist in this file.
I don't know what file you want to use, but this file don't has this content
admin/view/template/common/footer.tpl
Regards,
Miguel

titanuum mobile xmlmarkup events

moving from actionscript (flex) to titanium and I'm experimenting with the xml markup. What I have is a template that I picked up from the doc
<ItemTemplate name="template">
<ImageView left="0" bindId="pic" id="icon" />
<Label bindId="info" id="title"/>
</ItemTemplate>
</Templates>
my question is if someone clicks on the pic or a listitem itself, how does one handle the events. through xml markup? Then how do you reference any of the control wrap in the template?
I have tried
<ImageView left="0" bindId="pic" id="icon" onclick="doClick()" />
function doClick(e) {
alert($.info.text);
}
This just produces a error and I still would not know what pic was clicked.
any help would be great..
thanks Mike
Have you checked out the Alloy Quick Start? I think many of your questions can be answered there.
Anyway, for ListViews, you cant add an event listener to an item in the template, its just a template not an actual thing on the screen (yet), refer here, and look at the alloy section.
Instead you need the itemclick event listener on the ListView itself. Check , below for a simple example of what the XML markup looks like.
<ListView id="listView" defaultItemTemplate="template" onitemclick="yourEvent" >
<!-- The Templates tag sets the ListView's templates property -->
<Templates>
<!-- Define your item templates within the Templates tags or use the
Require tag to include a view that only contains an ItemTemplate -->
<ItemTemplate name="template">
<ImageView bindId="pic" id="icon" />
<Label bindId="info" id="title" />
<Label bindId="es_info" id="subtitle" />
</ItemTemplate>
</Templates>
<ListSection headerTitle="Fruit / Frutas">
<!-- You can specify any ListItem or ListDataItem properties in ListItem -->
<!-- Specify data to bind to the item template with inline attributes
defined as <bindId>:<Ti.UI.Component.property> -->
<ListItem info:text="Apple" es_info:text="Manzana" pic:image="/apple.png" />
<ListItem info:text="Banana" es_info:text="Banana" pic:image="/banana.png" />
</ListSection>
</ListView>
Also, you need any JavaScript to be in the controller files, not in the XML markup files. *.js has javascript that is behind the view, which is *.xml.

Field not displaying on list with Content types Inherits="False"

I've defined a content type 'related links' and set Inherits="False" and added line to remove out-of-the-box 'title' field as I don't want it showing in the view or new/edit/display forms, see (OPTION 1) in CAML below.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- ===== Fields ===== -->
<!-- Link Category -->
<Field DisplayName="Link Category"
Name="LinkCategory"
ID="{654EAC00-342B-4176-9D91-613AD724F684}"
Group="Custom"
Overwrite="True"
Type="Lookup"
ShowField="Title"
List="Lists/LinkCategoryList"
WebId="~sitecollection" />
<!-- ===== Content Type ===== -->
<!--
Related Links
- Parent ContentType: Item (0x01)
-->
<ContentType Name="Related Links"
ID="0x0100c11a1db14e564574bc49a2aa9bf325d3"
Group="Custom"
Description=""
Inherits="False"
Version="0">
<FieldRefs>
<!-- Title (OPTION 1) -->
<RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" />
<!-- (OPTION 2)
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
Hidden="TRUE" Required="FALSE" DisplayName="_hidden" />
-->
<!-- Link Category -->
<FieldRef DisplayName="Link Category"
Name="LinkCategory"
ID="{654EAC00-342B-4176-9D91-613AD724F684}"
Required="True" />
</FieldRefs>
</ContentType>
</Elements>
This does remove the 'title' field from the content type but when I try to associate the content type with a list it does not display the 'LinkCategory' field in the view or new/edit/display forms. Why is it so?
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint"
Title="Related Links"
FolderCreation="FALSE"
Direction="$Resources:Direction;"
Url="Lists/RelatedLinksListDefinition"
BaseType="0"
EnableContentTypes="True"
xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
<!-- Related Links -->
<ContentTypeRef ID="0x0100c11a1db14e564574bc49a2aa9bf325d3" />
</ContentTypes>
<Fields>
</Fields>
<Views>
<View ...etc...>
<ViewFields>
<FieldRef Name="LinkCategory"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
</View>
</Views>
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx"
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx"
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx"
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>
As a work around I've set Inherits="True" on the content type and used (OPTION 2) in content type CAML and that hides the 'title' field, but would really like to understand what's going on here and what's the best approach to take. Thanks in advance!
PS: This post has similar question: SharePoint 2010: RemoveFieldRef and Inherits="TRUE"
PSS: When I browse via SP Manager 2010 after deploying using OPTION 1, I get the following:
'Link Category' Field created correctly
'Related Links' Content Type created correctly with 'Link Category' field
'Related Links' list created with 'Related Links' Content Type associated
However 'Related Links' list has no reference to 'Link Category' Field.
Ok so was on my way up the garden path...
The issue why 'Link Category' Field was not being created on the 'Related Links' list wasn't related to setting Inherits="False", it was because I had not defined it in the list schema even though I'd defined it in the content type. As mentioned here:
http://msdn.microsoft.com/en-us/library/aa543576.aspx
When SharePoint Foundation creates a list instance, it includes only
those columns that are declared in the base type schema of the list or
in the list schema. If you reference a site content type in the list
schema, and that content type references site columns that are not
included in the base type schema of the list or in the list schema,
those columns are not included. You must declare those columns in the
list schema for SharePoint Foundation to include them on the list.
And here:
http://stefan-stanev-sharepoint-blog.blogspot.com/2010/03/contenttypebinding-vs-contenttyperef.html
One ugly thing about it is that you specify a site content type to be
attached to the list based on that list definition but the framework
doesn’t provision the fields in the content type if they are missing
in the list – so you need to add manually all content type’s fields in
the Fields element of the list schema file. This is actually what I
called the fields’ redefinition issue...
So duplicated Field element below from the content type definition to list schema:
<Fields>
<Field DisplayName="Link Category"
Name="LinkCategory"
ID="{654EAC00-342B-4176-9D91-613AD724F684}"
Group="Custom"
Overwrite="True"
Type="Lookup"
ShowField="Title"
List="Lists/LinkCategoryList"
WedId="~sitecollection" />
</Fields>
I can confirm that using Inherits="False" & <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" /> does remove the title field.
Here's another good link about Inherits="False" for those who stumble upon this post.
https://sharepoint.stackexchange.com/questions/2995/mysteries-of-the-contenttype-inherits-attribute

Provide new references for static blocks in Magento layout

I want to display a carousel and two banners at the top of each page content of my site.
I’ve created a custom reference starting from the footer block in page.xml.
So this is what it looks like:
<block type="page/html" name="topcontent" as="topcontent" template="page/html/topcontent.phtml">
<block type="page/html_wrapper" name="topcontent.container" as="topcontentContainer" translate="label">
<label>Page Top Content</label>
<action method="setElementClass"><value>topcontent-container</value></action>
</block>
<block type="core/template" name="topcontent.book.carousel" as="topcontentCarousel" template="callouts/book-carousel.phtml"/>
<block type="core/text_list" name="topcontent.left" as="topcontentLeft" />
<block type="core/text_list" name="topcontent.right" as="topcontentRight" />
</block>
Then I created a topcontent.phtml file where I put
<div class="topcontent-container">
<div class="topcontent">
<?php echo $this->getChildHtml('topcontentContainer') ?>
<?php echo $this->getChildHtml('topcontentCarousel') ?>
<?php echo $this->getChildHtml('topcontentLeft') ?>
<?php echo $this->getChildHtml('topcontentRight') ?>
</div>
</div>
I have my carousel displayed correctly, but when I try to put a block in topcontentLeft or topcontentRight, it is not displayed ad all.
I think I’m doing something wrong with the block type parameter, but I can’t figure out what: can someone provide me some help?
Thanks.
Depends on what you need to display in banner. If it's just some text you could use text block:
<block type="core/text" name="topcontent.right" as="topcontentRight">
<action method="addText"><text>Test text</text></action>
</block>
If you need placeholder block to show some CMS static block content, then you're right, cote/text_list is appropriate type for such block. It takes all it's nested blocks and render them one by one. So next you need to do is to put cms/block placeholder, its content could be added later from backend. All together it may looks like:
<block type="core/text_list" name="topcontent.right" as="topcontentRight">
<block type="cms/block" name="topcontent.right.cms" as="topcontentRightCms">
<action method="setBlockId"><block_id>topcontent_right_static</block_id></action>
</block>
</block>
Now you could create new static bloc in admin backend with 'topcontent_right_static' id and it'll be rendered in place where you output it.
I think the problem is in the #type attribute for topcontentLeft and topcontentRight
type="core/text_list" need to be changed to type="core/template"