Joomla 3.1 - Get active menu item url - joomla

As soon as I click on the "Media" item in my main menu, the following url is generated:
http://test.local/index.php/media-files
Now, I would like to create a module that is displayed only in media-files. Moreover, I want to retrieve the url of this active menu item.
So my question: How can I get the SEF-URL of an active menu item?
Thanks in advance,
enne

I think this might be what you want:
$app = JFactory::getApplication();
$menu = $app->getMenu()->getActive()->link;
echo JRoute::_($menu);
I've tested this as well, so let me know if it's what you require.

Related

How to make sidebar menu respond to URLs with parameters?

I define a URL in Slim such as:
$app->get('/dashboard/items?', ....
I then add a link to it in sidebar.twig, and sure enough, it becomes of class "active" once the link is visited.
However, if the URL contains parameters, the link no longer becomes "active".
e.g. /dashboard/items?page=3
I want the menu to recognize that we are still on the same page, and be highlighted as active. Best way to fix that?
Thank you
[UserFrosting 0.3.1]
UserFrosting determines which menu item to highlight by trying to match the current page URL against the URLs in the sidebar menu.
By default, it is configured to compare the entire URL, before any # hashes. To have it disregard your query parameters as well, try having it split the current URL on both # AND ?:
var url_head = url.href.split(/[#\?]+/, 1)[0];
return this.href == url_head;

How to have only one tab open in wxribbon bar in wxpython?

I am building a GUI and I am using wxribbon for wxpython. I want to have only one tab(ribbon page) in when user starts my app, from where user can dynamically add more pages or can add panels and buttons to a page. I am able to achieve all the dynamic parts of ribbon. The only problem I have is that I am unable to start with only one ribbon page. When I define only one page, I don't see the ribbon bar(tab bar), what I see is only the page. Now, when I define two page in the beginning, then I see the bar. Can someone tell me what I code have to change in wxribbon so that I am able to have a tab bar visible with only one page in it. Any help would be great. Thanks!. The sample code I am using to add a page is as follows :
import wxRibbon as RB
self._ribbon = RB.RibbonBar(self, id = wx.ID_ANY)
page_1 = RB.RibbonPage(self._ribbon, WORKPIECE, "Workpiece", Bitmap("eye.xpm"))
page_2 = RB.RibbonPage(self._ribbon, wx.ID_ANY, "New Tab", Bitmap("empty.xpm"))
You need the flag RIBBON_BAR_ALWAYS_SHOW_TABS
try this:
self._ribbon = RB.RibbonBar(self, wx.ID_ANY, agwStyle = RB.RIBBON_BAR_DEFAULT_STYLE | RB.RIBBON_BAR_ALWAYS_SHOW_TABS)

How to set titles for the web pages?

I have 2.5.6, how can I create a new web page with a new title? Now I have a navigation bar and the title of the pages correspond to the text in the items in the navigation bat, how can I create titles that are not the same as the items' content in the navigation bar? For exampe for the item "Home" the title of the page now is also "Home".
If you use the Help button in the toolbar for a menu item you'll find there is a section called "Page Display Options" the first field is called "Browser Page Title"
The "Browser Page Title" is described as optional text for the "Browser page title" element. If left blank, the default value is used based on the Menu Item Title..
From the Forum
You can go to Global Config > Site > SEO Settings there is an
option to include site name in page titles so you would then get
"article title - site name" as your page title.
ccpl's anwser is valid but that would be a static title. If you would like to have a dynamic title where it would change depending where you visit you will have to code it.
For example, if your site is a dictionary where you had the alphabet in the same menu the static title wouldn't ever change even if you chose any of those letters.
To make a dynamic title using code so it would change you should use this:
This is an example of a site that I'm developing where the title changes depending on the name you click on (the site is about terms & definitions).
$doc =& JFactory::getDocument();
$db = JFactory::getDBO();
$select="SELECT name";
$from="FROM #__csglosary_terms ";
$where="WHERE id=".$this->item->id;
$query=$select.$from.$where;
$db->setQuery($query);
$title=$db->loadResult();
$doc->setTitle("Glosary of terms and definitions - Term ".ucfirst($title)." - Dictionary of terms used in hotels, restaurants.");
The variable $title returns the term you have clicked on and will show up on the pages title.
Hopefully this helps you also :).

How to hide Edit and Delete actions from Show view in ActiveAdmin?

just added Active Admin to my project. I want hide the Edit & Delete action form the Show page, and Edit & Delete action should present in Index page.
Is there a better way to do this?
Thanks in advance.
Did you try
ActiveAdmin.register FooBar do
config.action_items.delete_if { |item|
# item is an ActiveAdmin::ActionItem
item.display_on?(:show)
}
end
?
you can find other workarounds in this thread https://github.com/gregbell/active_admin/issues/760

Joomla 2.5 - Visible Menu Item - but need login to access

I followed this tutorial about ACL - http://community.joomla.org/blogs/community/1252-16-acl.html
To make everything clear: this is what I need:
having a menu item that is linking to an article
a user enters (not logged yet) the web site (it does not matter if the user is already registered or not)
this user should see the menu item
the user clicks on the menu item
if the user is NOT logged in - the user is asked to enter the username/pass
if the user is logged in -> goto 6
after login is ok, the user can see the content of the article where the menu item was linked.
My aim is to have a menu item that would be visible for all users: logged in and not logged in. But when clicked - only logged in users can view the content where the menu item is pointing. In case the user is not logged in -> log in form should be displayed.
After following the above tutorial I got a menu item that is completely invisible for users that are NOT logged in.
How can I make the menu item to be visible for all, but need login to see content?
Thank you.
EDIT 1:
I just found this solution http://docs.joomla.org/Auto_redirect_guests_to_login
Is it the only solution? I have a huge tree menu structure. That means I need to have a clone of my huge menu... And everytime I change a menu item name - I should do it twice (in visible menu and in invisible menu).
Are there any other solutions without having 2 menus?
EDIT 2:
Found another solution (hacking core files).
This is when menu item is set to "public" but the article ACL is set to "registered"
components/com_content/views/article/view.html.php
from
// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') != true && (($item->params->get('show_noauth') != true && $user->get('guest') ))) {
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
to
// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') != true && (($item->params->get('show_noauth') != true && $user->get('guest') ))) {
// Redirect to login
$uri = JFactory::getURI();
$app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('Members please login to view this page. If you are not a member please <a href="/component/users/?view=registration">register here<a>'));
return;
}
How can I override that code and avoid hacking core files?
Or maybe there is a more elegant solution?
Thanks.
What you can do is a template override and add the login form to the page that provides the message. A template override will allow you to add extras to pages without hacking the core files, therefore when updating Joomla, it will still be there.
For more information on how to override, please see the link below:
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
Hope this helps.

Resources