How to show the language menu shown in the AdminLTE examples - laravel

I have built a small web application using Laravel 8 and I was requested to integrate AdminLTE to it.
I am new to AdminLTE and part of the requirements is to translate the pages content, but I had no idea of how to create such menu.
The idea is to come to this:

Here I want explain how I got there. It took me some hours to understand how this works so I think someone else could benefit from my work.
I am assuming you have already successfully integrated the AdminLTE dashboard to your Laravel application.
The key is to open the file C:\your_web_app_folder\config\adminlte.php with your preferred text editor.
Find the "Menu Items" section and add the following text inside the 'menu' => [] element:
[
'text' => 'Language',
'topnav_right' => true,
'icon' => 'flag-icon flag-icon-us',
'submenu' => [
[
'text'=>'English',
'icon' => 'flag-icon flag-icon-us',
'url'=> '#'
],
[
'text'=>'Khmer',
'icon' => 'flag-icon flag-icon-kh',
'url'=> '#'
]
]
],
Such text can be inserted after the search textbox or wherever you consider it more convenient to you.
The 'text' sets the text that will be shown on your link (optional).
The 'topnav_right' indicates that the language menu will be located on the right side of the navigation bar.
The 'icon', in this case, is going to contain the CSS class that will display the desired icon flag. For this to work, it is necessary to load the respective CSS file which is located in the folder \public\vendor\flag-icon-css\css\flag-icon.css, assuming you previously published those assets using the artisan commands specified in the documentation (https://github.com/jeroennoten/Laravel-AdminLTE/wiki/5.-Artisan-Console-Commands)
Proceeding like this you will have all those CSS/JS/images copied to your \public\vendor folder for easier reference.
There is nothing else to do to create those menus you see on the top nav (notifications, messages, languages, etc). All of them can be built in the same way.

Related

How to set a display icon depending on file type- Laravel

I'm currently making a web application that enables users to upload their files. Everything is working fine so far. I was asked to add a display icon on the side of the file that was uploaded.
How do I set an image to be displayed when a certain file type is uploaded?
Adding an accessor method in your file model like;
public function getIconAttribute() {
$extensions = [
'jpg' => 'jpeg.png',
'png' => 'png.png',
'pdf' => 'pdfdocument.png',
'doc' => 'wordicon.jpg',
];
return array_get($extensions,$this->extension,'unknown.png');
}
The array_get is a laravel helper that looks up a value in an array and can have a third parameter of a default if the extension is not found in the array.
Then in blade you can just icon}}' />
Or
A simpler approach where you just make sure to name the icon the same as the extension.
Then in blade you can just extension}}.png' /> and then you don't need to add the accessor at all.
It does not though allow for unknown file types but this might be ok if you are restricting the types of upload (which you should).

Calling an image alt text with Ruby Watir

Ok, I'm trying to access an image stored in an image library which on click closes the image library pop up and inserts the image into the page.
The html for the image is;
<img src="/uploads/images/thumbs/10.png?504" alt="Find Us" width="140" onclick="$('#removeButton', window.opener.document).show();
$('#myImgId', window.opener.document).show();
$('#imageHeadingID', window.opener.document).val('13');
$('#myImgId', window.opener.document).attr('src', '/uploads/images/thumbs/10.png');
window.close()">
As a note, the ?504 is not static and changes each time the image library is open so I cant use it as an id value.
I've tried the following lines of code in turn, all without success (gleaned from google and stack overflow).
find("img[#alt='Find Us']").click
$browser.cell(:text => "Find Us").click
$browser.image(:src => /10/).click
$browser.image(:src => "/10.png").click
$browser.link(:text => "Find Us").click
any help would be appreciated
Try identify by :alt :
$browser.image(:alt => "Find Us").click
But, it's strange, cause, $browser.image(:src => /10/).click - must work also.
I agree with Alex and Justin that using src should work, but
Have you tried using an XPath?
Something like browser.img(:xpath => "/html/.../img").click
You can get the XPath to the image pretty easily with Chrome by right-clicking the image-->Inspect Element-->then right-click on the relevant line of HTML in the developer tools that have opened. If the image is always in the same place on the page (regardless of any change in the src), this method should work.

Edit JomSocial Joomla Registration Page & Adding Content

I'm running JomSocial 3.2 on Joomla 3.
I want to add some content to the right side of the registration page.
Some pictures and other contents.
So far, i've been able to get to the "register.index.php" file,
which is the file that displays some of the content in the homepag.
The file is in: "/site_root/components/com_community/templates/default/" folder
but i've not been able to fully edit the whole registration page.
This could be done in many different ways - even without editing any file. Install this extension: http://extensions.joomla.org/extension/advanced-module-manager and when editing module you'll have additional tab called "tasks" There will be field URL, type inside URLs of your registration form. Thanks to this you'll be able to assign modules to registration form.
You could also override for:
ROOT/components/com_community/templates/default/register.index.php
Copy it to:
ROOT/templates/your-template/html/com_community (if you don't have "html" or "com_community" folders, feel free to create them)
Then you may create module position inside file using this code:
$modules = JModuleHelper::getModules( 'reg-positon' );
foreach ($modules as $module) {
$_options = array( 'style' => 'xhtml' );
echo JModuleHelper::renderModule( $module, $_options );
}
Above code creates module position: "reg-positon'. You'll need to type this name manually as it will be not listed on module positions list.
Now you'll need a bit of html to display it on right or left of registration form.

Add a quick icon in Joomla 3

Anyone know how to add a quick icon or maybe even edit the current list of quick icons in Joomla 3.1? To be more specific, that would be the series of links that appear on the right side of the screen immediately after logging in to Joomla admin. I searched and couldn't find this question on stackoverflow.
QuickIcon's are actually a plug-in.
If you go to Extensions->Plug-in Manager->Plug-ins and select quickicon from the Type filter menu on the left you will see the any QuickIcon plugins you have installed. The default plug-ins are for Update Notifications (one for Joomla and another for Extensions).
If you are creating on as a simple short-cut to existing functionality then you're best of using one of the QuickIcon extensions on the Joomla Extension Directory that do that already. If you're wanting to create a QuickIcon for a custom component you're creating you will need to create your own plug-in.
You can read about Plug-ins here, note that for 3.x there isn't much difference from 2.5.x plugins.
A QuickIcon plug-in consists of several files:
pluginname.php
pluginname.xml
various media files (images, css, js)
While the #3 is optional most plugins will use one or more of them.
If you're going to create your own plug-in I would start by looking at the two notification QuickIcon plugins that ship with Joomla 3.x. You can find them in the /plugins/quickicon/ directory with corresponding media in /media/plg_quickicon_*. As they ship with the core their CSS is in the admin templates CSS' e.g. if you using Isis you will find it in /administrator/templates/isis/css/template.css
If you go to the following file:
administrator/modules/mod_quickicon/helper.php
You will see on the start of line 51, arrays such as the following:
array(
'link' => JRoute::_('index.php?option=com_content&task=article.add'),
'image' => 'file-add',
'icon' => 'header/icon-48-article-add.png',
'text' => JText::_('MOD_QUICKICON_ADD_NEW_ARTICLE'),
'access' => array('core.manage', 'com_content', 'core.create', 'com_content', )
)
Line 1, is the link.
Line 2, go to media/jui/css/icomoon.css to see what is available.
Line 3, I'm not actually too sure about but will update when I do.
Line 4, is the text such as Add New Article, but as you can see
above, it's a language string
Line 5 is the text you see such as "Add New Article", but in the code above, it's a language string
Hope this helps
Here is the standard solution:
Copy the file default.php from
/administrator/modules/mod_quickicon/tmpl/
to
/administrator/templates/YOUR_CURRENT_ADMIN_TEMPLATE/html/mod_quickicon/
and open the copied file. Replace this line
$html = JHtml::_('links.linksgroups', ModQuickIconHelper::groupButtons($buttons));
with these lines:
$myLinks = array(
'COM_YOUR_COMPONENT_QUICKICON_YOUR_GROUP' => array(
array(
'link' => JRoute::_('index.php?option=com_YOUR_COMPONENT'),
'image' => 'pictures',
'icon' => 'header/icon-48-article-add.png',
'text' => JText::_('COM_YOUR_COMPONENT_QUICKICON_YOUR_ITEM'),
'access' => array('core.manage', 'com_YOUR_COMPONENT'),
'group' => 'COM_YOUR_COMPONENT_QUICKICON_YOUR_GROUP'
),
)
);
$array = ModQuickIconHelper::groupButtons($buttons);
$array = array_merge($myLinks, $array);
$html = JHtml::_('links.linksgroups', $array);
For languages, use overrides like this:
/administrator/language/overrides/en-GB.override.ini
Quickicons can be added easily using plugin in Joomla 3.x and Joomla 2.5
This plugins can be used as an example https://github.com/joomla/joomla-cms/tree/staging/plugins/quickicon/joomlaupdate

Magento Widget - How to confirm access to block code?

I have created my first Magento widget on a test site (same code and configuration as my live site). The widget works perfectly on the test site. However, having moved the code to the live site, I can configure the widget instance, but the output of the widget is not showing on the product page. So I know Magento is pulling information from the widget's config.xml and widget.xml files.
I have confirmed that the correct layout update is being inserted in the core_layout_update table. The information on the live system's table is exactly the same as that on the working test site.
I have confirmed that the file permissions and ownership are correct on the live site.
I have confirmed that I can put another (Magento supplied) widget in the exact spot on the configurable product page (Product Extra Info). So I know that my templating, etc. is not getting in the way of adding the widget in that spot.
I've tried deleting the widget instance and recreating a new instance of the same widget.
I have compared the code to the test site and copied the code straight from the test site. Still no success. I have enabled php_flag display_errors in .htaccess and no errors are shown. And no errors are showing in the exception.log when enabled.
The live and test systems are on different servers, different OS's, different versions of PHP (both 5.3.x). I've refreshed all the caches and confirmed that the test widget is showing so I don't think this is a caching issue.
How is the best way to confirm that Magento on the live site can actually access or find the Block code for my widget? As indicated I know Magento is accessing the widget.xml file in my local code directory. Not sure if installing Alan Storm's CommerceBug is the way to trace or dump what Magento is trying to load (modules, widgets, etc) for the page in question.
Verify that you have your xml in the /app/etc/modules folder.
You can turn on Block Hints by going to Admin->System->Configuration->Advanced->Developer, change the Current Configuration Scope to Main Website and click on Debug. Change Template Path Hints to Yes and save.
Verify your filenames. This has gotten me a number of times. I develop on a Mac (non case-sensitive), and occasionally when I upload to Linux (case-sensitive), it breaks. One of the first thing I check is the file name's case.
Ensure that the class name matches the filename.
The next step I'd take is to take a look at the final page layout xml generated for the page your'e adding the widget to and ensure a bit of Layout XML is being added to the page for your widget. If it isn't, there's something wrong with the Layout XML Updates that are added to the table via the widget UI. If it is, then start debugging why the particular chunk of generated layout XML isn't being added to the page.
This is the top-down approach to debugging the problem, but it's the only way I know to be sure.
I had the same problem. It's my decision:
app\code\local\Mage\Core\Model\Resource\Layout.php
When 'theme' => Mage::getSingleton('core/design_package')->getTheme('layout') result is not correct: 'theme' => 'multistore', should be 'theme' => 'your_theme'.
So, delete argument 'layout' in function getTheme() and get right result
*/
class Mage_Core_Model_Resource_Layout extends Mage_Core_Model_Resource_Db_Abstract
{
...
public function fetchUpdatesByHandle($handle, $params = array())
{
$bind = array(
'store_id' => Mage::app()->getStore()->getId(),
'area' => Mage::getSingleton('core/design_package')->getArea(),
'package' => Mage::getSingleton('core/design_package')->getPackageName(),
// 'theme' => Mage::getSingleton('core/design_package')->getTheme('layout')
'theme' => Mage::getSingleton('core/design_package')->getTheme()
);
foreach ($params as $key => $value) {
if (isset($bind[$key])) {
$bind[$key] = $value;
}
}
$bind['layout_update_handle'] = $handle;
$result = '';
$readAdapter = $this->_getReadAdapter();
if ($readAdapter) {
$select = $readAdapter->select()
->from(array('layout_update' => $this->getMainTable()), array('xml'))
->join(array('link'=>$this->getTable('core/layout_link')),
'link.layout_update_id=layout_update.layout_update_id',
'')
->where('link.store_id IN (0, :store_id)')
->where('link.area = :area')
->where('link.package = :package')
->where('link.theme = :theme')
->where('layout_update.handle = :layout_update_handle')
->order('layout_update.sort_order ' . Varien_Db_Select::SQL_ASC);
$result = join('', $readAdapter->fetchCol($select, $bind));
}
return $result;
}
}

Resources