I wanted to add a new custom menu with submenus, and researched on official WHMCS documentation, but found only this:
<?php
#adding Menu Item to primaryNavbar
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
$primaryNavbar->addChild('Menu Name')
->setUri('https://www.example.com/')
->setOrder(70);
});
But question is, how to add menu with submenus inside?
So a menu with sub menu items in WHMCS's client interface is just a menu item with children. The example code you cite creates a menu item, to make sub menus just add more children to the result of your addChild() call. Like this:
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
$menuItem = $primaryNavbar->addChild('Menu Name')
->setUri('https://www.example.com/')
->setOrder(70);
$menuItem->addChild('Sub Menu Item 1')->setUri('foo');
$menuItem->addChild('Sub Menu Item 2')->setUri('bar');
return $primaryNavbar;
});
Login to your whmcs installation folder -> includes -> hooks folder
create a new php file with the above code.
Edit the Menu name, https://www.example.com/ with your details and save the file
Thats all!
Related
I'm a complete Modx newbie and I'm trying to update an existing website. My goal is to add a new category to some pages as shown in the table below:
Checkout the documentation for this here https://bobsguides.com/creating-a-new-category.html
To create a new Category
Click on the Elements tab in the tree at the left in the Manager
Right-click on the "Categories" folder in the Element tree
Select "New Category"
Enter a Name for your new Category
(Optional) Enter a parent Category if you want to have Categories within Categories
It seems your question about MIGX TV functionality, this is how you should solve this:
Update your MIGX TV with the next category field (in Form tabs):
{"field":"category", "caption":"category", "inputTVtype":"listbox",
"inputOptionValues":"#EVAL return $modx->runSnippet('getCategoryList');"}
Create snippet getCategoryList with next code inside:
<?php
$result = array();
$c = $modx->newQuery('modCategory');
$c->sortby('category','ASC');
$categories = $modx->getCollection('modCategory',$c);
foreach($categories as $category){
$result[] = $category->get('category')."==".$category->get('category');
}
return implode("||", $result);
When I selected some text, the context menu title is updated. For instance:
Is it possible to do this as an extension developer?
My current code:
chrome.contextMenus.create({
"title":"I WANT THIS UPDATED",
"contexts":["browser_action"],
"onclick":function(info, tab) {
chrome.tabs.create({url: 'https://www.facebook.com/'});
}
});
Thanks,
Yes, it's possible, but not for browser_action context.
The screenshot you're showing is for selection context.
Quoting the documentation:
When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin".
See this answer for more info on context types.
I have a taxonomy named My Taxonomy with four terms: TermA, TermB, TermC, TermD. I also have a navigation menu into which I added this taxonomy as a link.
Here are the relevant Edit Taxonomy Link values:
Taxonomy My Taxonomy
Root Term Parent Taxonomy
Display top level menu item false (or true - neither works)
Levels to display 0
Menu text My Taxonomy <----- (this is what Orchard isn't rendering)
What I want on the front end:
My Taxonomy
TermA
TermB
TermC
TermD
What I get on the front end:
TermA
TermB
TermC
TermD
How do we cause Orchard to render a Taxonomy Links Menu text?
Edit:
This is my current kludge in pseudo code:
for (var i = 0; i < childMenuItems.Count; ++i)
{
var childMenuItem = childMenuItems[i];
if (childMenuItem.Content is TermPart)
{
// render the taxonomy terms
var taxonomyName = childMenuItem.Content.Container.TaxonomyPart.Name;
var termMenuItems = (childMenuItems as ICollection<dynamic>).Where(c =>
c.Content is TermPart &&
c.Content.Container.TaxonomyPart.Name.Equals(taxonomyName));
i += termMenuItems.Count();
// rest omitted
}
}
Seems like you missed this checkbox: [] Display top level menu item. You'll need a root term to contain the others. If you don't like that solution, just add a static menuitem with the name of your taxonomy and put your taxonomy menu items under it.
i want to add some functionality in combo box. I want that it should behave like Google's Search Box. Like i have added items in combo box from a database Say Name of the Doctors.
i want that as user type name of the doctor or first letter of the name of the doctor, the selection bar goes automatically only to related names.
Any suggestion friends???
try AutoCompleteMode of combobox, something like this:
сomboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
сomboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
comboBox.AutoCompleteCustomSource = MyStringData();
where myStringData is :
public AutoCompleteStringCollection MyStringData()
{
var collection= new AutoCompleteStringCollection();
//you can add names of the doctors retrieved from the database here
collection.Add("one");
collection.Add("two");
collection.Add("three");
collection.Add("four");
return collection;
}
this would suggest those items which begins with those you typed.
If you want to show selection (highlighting) as you type, you can be a little more creative and create a simple combination of a textbox and gridView, which gets bound everytime TextChanged happens on the textBox
I've been trying to find a way of forcing an attribute to show as a dropdown rather than a block of options but had no luck. The code current looks like this:
case 'select': ?>
<div class="input-box"> <?php echo $this->getAttributeSelectElement($_attribute) ?> </div>
<?php endswitch; ?>
Does anyone know how to make this look like a dropdown list instead?
Thanks in advance
I had the same problem earlier today and the strangest thing was that I had the attributes (drop down) with the same properties but one displaying a drop down menu and the other a multi select menu in the advanced search.
I did some testing with different settings and it turned out that in the advanced search every attribute that is a list (drop down and multi-select) and it has more than 2 options is displayed as multi-select.
I had a look at Mage_CatalogSearch_Block_Advanced_Form stored in /app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php and I saw where this condition of 2 is checked. The magento core team made it like this to make sure that the 'yesno' or boolean list are displayed as dropdown.
In the above mentioned file, starting from line 173 (on the current version of magento)
is the following code:
public function getAttributeSelectElement($attribute)
{
$extra = '';
$options = $attribute->getSource()->getAllOptions(false);
$name = $attribute->getAttributeCode();
// 2 - avoid yes/no selects to be multiselects
if (is_array($options) && count($options)>2) {
. . .
If you change the number two on the last line with the number 5, advanced search will display drop down menu on every attribute that has less than 6 options.
What I did for myself is I added a new method, getAttributeDropDownElement(), bellow getAttributeSelectElement() that looks like this:
public function getAttributeDropDownElement($attribute)
{
$extra = '';
$options = $attribute->getSource()->getAllOptions(false);
$name = $attribute->getAttributeCode();
// The condition check bellow is what will make sure that every
// attribute will be displayed as dropdown
if (is_array($options)) {
array_unshift($options, array('value'=>'', 'label'=>Mage::helper('catalogsearch')->__('All')));
}
return $this->_getSelectBlock()
->setName($name)
->setId($attribute->getAttributeCode())
->setTitle($this->getAttributeLabel($attribute))
->setExtraParams($extra)
->setValue($this->getAttributeValue($attribute))
->setOptions($options)
->setClass('multiselect')
->getHtml();
}
The next thing you need to do is a small if statement within the switch of the form (see bellow) that will check the name of the attribute and base on that to call either getAttributeSelectElement() or our new method getAttributeDropDownElement(). I leave this job to you :)
case 'select': ?>
<div class="input-box"> <?php echo $this->getAttributeSelectElement($_attribute) ?> </div>
<?php endswitch; ?>
Sorry for my English...i'm french ;-)
In your admin panel, you can choose the type of your Attributes
Make sure that your attribute is declared as a list. In my Magento version, it's the third information in the attribute admin panel after code and scope.
PoyPoy
Magento has a class for generating selects available as a Mage_Core_Block_Html_Select class (/app/code/core/Mage/Core/Block/Html/Select.php).
On your design template directory template/catalogsearch/advanced/form.phtml, replace
echo $this->getAttributeSelectElement($_attribute);
With
echo $this->getLayout()->createBlock('core/html_select')
->setOptions( $_attribute->getSource()->getAllOptions(true))
->setName($_attribute->getAttributeCode())
->setClass('select')
->setId($_attribute->getAttributeCode())
->setTitle($this->getAttributeLabel($_attribute))
->getHtml();