The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 28 posts ] 
Author Message
PostPosted: Sat Jan 23, 2010 6:34 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
This is a modification I wanted for awhile, and am sharing it with you guys. I wanted to be able to choose the "External Link" option for the menu item, and have some options to choose if it is a lightbox(ajax) popup or regular popup, and to be able to choose the width and height of that popup.

Only two files need to be modified for this on Joomla 1.5.15:

- administer/components/com_menus/models/metadeta/url.xml
- modules/mod_mainmenu/legacy.php

First add this to the url.xml file, under the first "menu_image" parameter:

Code:
<param name="popuptype" type="list" default="popup1" label="Popup Window Type" description="Popup Window Type">
           <option value="popup1">Lightbox Popup - Ajax</option>
          <option value="popup2">Regular Popup</option>
          </param>

          <param name="popupwidth" type="text" default="600" label="Popup Width" description="Popup Window Width"></param>
         <param name="popupheight" type="text" default="600" label="Popup Height" description="Popup Window Height"></param>


Then in the modules/mod_mainmenu/legacy.php file, around line 121 under this:
Code:
$mitem->name = stripslashes(htmlspecialchars($mitem->name));


ADD

Code:
$popupmethod = $menu_params->def('popuptype');
   $popupmethodwidth = $menu_params->def('popupwidth');
   $popupmethodheight = $menu_params->def('popupheight');


Then below around line 135 you will see "case 2 :". Everything under case 2, all the way to "case 3 :", replace with this code:
Code:
if ($popupmethod == 'popup1')
       {
   $txt = "<a href=\"" . $mitem->url . "\" rel=\"width[" . $popupmethodwidth . "];height[" . $popupmethodheight . "];\" class=\"$menuclass jcepopup\" " . $id . ">" . $mitem->name . "</a>\n";
      break;
       }
          if ($popupmethod == 'popup2') {
             $txt = "<a href=\"#\" onclick=\"javascript: window.open('" . $mitem->url . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" . $popupmethodwidth . ",height=" . $popupmethodheight . "'); return false\" class=\"$menuclass\" " . $id . ">" . $mitem->name . "</a>\n";
         break;
          }


That is it for that part. For the lightbox to work you need to have a plugin like JCE Utilities installed that applies the lightbox effect to any links that have the class it requires. In the code above the class is "jcepopup" and is at the end of the normal menu class because that is what JCE Utilities requires. But your lightbox script might use something different like "shadowbox" so change it accordingly.

Also the syntax for the lightbox width and height above is for JCE popup, and usually is the same for all lightbox scripts, but it might need to be changed if a different syntax is used by your script.

IMPORTANT NOTE: The "On Click, Open in:" option under the external menu link "Menu Item Details" options needs to be set to "New Window Without Browser Navigation" for it to work also.

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Mon Jan 25, 2010 8:34 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Jan 25, 2010 8:28 pm
Posts: 2
This is still not working for me :S


Top
 Profile  
 
PostPosted: Mon Jan 25, 2010 8:56 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
You have Joomla 1.5.15?

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Mon Jan 25, 2010 9:39 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Jan 25, 2010 8:28 pm
Posts: 2
Yeh, I have version 1.5.15


Top
 Profile  
 
PostPosted: Tue Jan 26, 2010 2:37 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
Hmmm, well the only other thing I can think of is you are not setting the link to open in a new window. Did you choose that option? If so then you might want to double check over my instructions, I wrote them while doing it and it works fine for me.

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Thu Feb 25, 2010 1:51 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
Hi,

for me it also doesnt work. I tried different settings in JCE Utilities but nothing works. The external page opens everytime in a new tab...

what do you mean with this:

Quote:
That is it for that part. For the lightbox to work you need to have a plugin like JCE Utilities installed that applies the lightbox effect to any links that have the class it requires. In the code above the class is "jcepopup" and is at the end of the normal menu class because that is what JCE Utilities requires. But your lightbox script might use something different like "shadowbox" so change it accordingly.

Also the syntax for the lightbox width and height above is for JCE popup, and usually is the same for all lightbox scripts, but it might need to be changed if a different syntax is used by your script.


my english is not the very best and perhaps i have to do something more...


Top
 Profile  
 
PostPosted: Thu Feb 25, 2010 2:01 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
A lightbox popup plugin needs to be installed. There are many out their for Joomla, one being JCE Utilities (now replaced by JCE MediaBox). Whichever one you choose, you just need to install the plugin and find out what class needs to be applied to the link for it to open in a lightbox.

For example the JCE Utilities plugin requires the class "jcepopup" to be added to a link that you want to open in a lightbox. If you don't have that class applied to the link, it will NOT open in a lightbox. Whichever one you do choose though, in the modification I have shown above, you need to change the class accordingly.

Is this more clear?

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Thu Feb 25, 2010 2:08 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
Yes! Thanks...

You made this one with the class jcepopup class or do I have do add this anywhere?? Because this normally should work because I use this plugin too.


Top
 Profile  
 
PostPosted: Thu Feb 25, 2010 2:18 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
Code:
class=\"$menuclass jcepopup\"


Yep, it is called right their, and that's where it will need to be changed if you ever change your lightbox plugin and the class changes.

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 9:31 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
So I tried to find my mistake, but I dont find it. On the Basic Parameters i took Lightbox Popup. Now there are three types at "on click..." and here are the three generated codes:

Case I:
Code:
li class="item101"><a href="http://www.google.de/movies?bielefeld"><span>Kinoprogramm</span></a></li>


Case II:
Code:
<li class="item101"><a href="http://www.google.de/movies?bielefeld" target="_blank"><span>Kinoprogramm</span>


CaseIII:
Code:
<li class="item101"><a href="http://www.google.de/movies?bielefeld" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,');return false;"><span>Kinoprogramm</span></a></li>


So I think, that there is missing the class... any idea where could me my bug??


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 2:41 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
Only case 2 needs to be replaced with the code I showed above. It doesn't look like you did that, so that might be the problem.

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 4:02 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
Here my code in modules/mod_mainmenu/legacy.php

Code:
// cases are slightly different
case 1 :
// open in a new window
$txt = '<a href="' . $mitem->url . '" target="_blank" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
break;

case 2 :
// open in a popup window
if ($popupmethod == 'popup1')
       {
   $txt = "<a href=\"" . $mitem->url . "\" rel=\"width[" . $popupmethodwidth . "];height[" . $popupmethodheight . "];\" class=\"$menuclass jcepopup\" " . $id . ">" . $mitem->name . "</a>\n";
      break;
       }
if ($popupmethod == 'popup2') {
             $txt = "<a href=\"#\" onclick=\"javascript: window.open('" . $mitem->url . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" . $popupmethodwidth . ",height=" . $popupmethodheight . "'); return false\" class=\"$menuclass\" " . $id . ">" . $mitem->name . "</a>\n";
         break;
          }

case 3 :
// don't link it
$txt = '<span class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</span>';
         break;

default : // formerly case 2
// open in parent window
$txt = '<a href="' . $mitem->url . '" class="' . $menuclass . '" ' . $id . '>' . $mitem->name . '</a>';
break;
}


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 4:09 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
Ok so you also added this to that file where I specified (make sure):

Code:
$popupmethod = $menu_params->def('popuptype');
   $popupmethodwidth = $menu_params->def('popupwidth');
   $popupmethodheight = $menu_params->def('popupheight');


And this to the url.xml file under /administrator/components/com_menus/models/metadeta/url.xml

Code:
<param name="popuptype" type="list" default="popup1" label="Popup Window Type" description="Popup Window Type">
          <option value="popup1">Lightbox Popup - Ajax</option>
          <option value="popup2">Regular Popup</option>
          </param>

         <param name="popupwidth" type="text" default="600" label="Popup Width" description="Popup Window Width"></param>
         <param name="popupheight" type="text" default="600" label="Popup Height" description="Popup Window Height"></param>

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 4:18 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
I think so:

Code:
// replace & with amp; for xhtml compliance
   // remove slashes from excaped characters
   $mitem->name = stripslashes(htmlspecialchars($mitem->name));
      $popupmethod = $menu_params->def('popuptype');
      $popupmethodwidth = $menu_params->def('popupwidth');
      $popupmethodheight = $menu_params->def('popupheight');
   switch ($mitem->browserNav)


Code:
<?xml version="1.0" encoding="utf-8"?>
<metadata>
   <state>
      <name>External Link</name>
      <description>External link parameters...</description>
      <params>
         <param name="menu_image" type="imagelist" directory="/images/stories" hide_default="1" default="" label="Menu Image" description="PARAMMENUIMAGE" />
          <param name="popuptype" type="list" default="popup1" label="Popup Window Type" description="Popup Window Type">
          <option value="popup1">Lightbox Popup - Ajax</option>
          <option value="popup2">Regular Popup</option>
          </param>

         <param name="popupwidth" type="text" default="600" label="Popup Width" description="Popup Window Width"></param>
         <param name="popupheight" type="text" default="600" label="Popup Height" description="Popup Window Height"></param>
      </params>
      <advanced />
   </state>
</metadata>


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 4:33 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
Well do you mind checking? All that code is needed for it to work.

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Tue Mar 02, 2010 5:00 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
I checked it twice...

At this time it doesnt matter if I set it to popup1 or to popup2 in the backend - I get everytime the same link code on the page.

Do I need anywhere writing rights?
Can I look anywhere which popup is set to the menue?


Top
 Profile  
 
PostPosted: Wed Mar 03, 2010 9:21 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
No, all that is needed is the changes I have shown above. I even went through them again on a fresh installation and got it working just fine. Are you using Joomla 1.5.15 or something else? Also show me the code that is displayed on the front end of your site for that link when you try to use it, and remember it needs to also be set to open in a new window, and it needs to be an external link menu item! It will not work with any other menu item types.

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Thu Mar 04, 2010 9:15 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
I attached a link where you can see the settings in the backend:

Attachment:
external_link.jpg


I'm testing with a google link - so its an external link. Here the generated code from the frontend site:

Code:
<li class="item101"><a href="http://www.google.de/movies?bielefeld" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,');return false;"><span>Kinoprogramm</span></a></li></ul>


This seems to be the normal pop methode also I took the Lightbox Popup. During my test I found out, that it doenst matter which methode I take (Lightbox or normal popup). The generated code everytime is the same.


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Thu Mar 04, 2010 2:33 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
I don't see the jcepopup class in the link code. It has to be there for it to work, and if you added everything under case 2 it should be there. You did add the code only under case 2 right? And case 2 is "Open Browser WITH Navigation Bar". The screen shot you took I see you chose to open without navigation. That is case 3, so if you want that option to do it replace the code under case 3 with the case 2 code above.

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Thu Mar 04, 2010 3:22 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
i know - but anywhere seems to be a mistake, but I cannot find it.

Attachment:
external_link.jpg


Code:
<li class="item101"><a href="http://www.google.de/movies?bielefeld" target="_blank"><span>Kinoprogramm</span></a></li></ul>   


it is also without lightbox :(


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Thu Mar 04, 2010 3:32 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
Maybe you can just send me the two files I say that need to be modified, and I can make the mods myself for you? Just let me know if that's okay with you, and I will PM you my email.

Also the problems I find in your files I will post on the forum here for others to see who might have done the same thing, if I find any that is.

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Thu Mar 04, 2010 3:42 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
Yes - sounds good


Top
 Profile  
 
PostPosted: Fri Mar 05, 2010 8:57 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Aug 22, 2009 4:45 pm
Posts: 16
Also Code Under CASE 2 above is now changed to:

Code:
if ($popupmethod == 'popup1')
       {
   $txt = "<a class=\"$menuclass jcepopup\" " . $id . " href=\"" . $mitem->url . "\">" . $mitem->name . "</a>\n";
      break;
       }
          if ($popupmethod == 'popup2') {
             $txt = "<a href=\"#\" onclick=\"javascript: window.open('" . $mitem->url . "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" . $popupmethodwidth . ",height=" . $popupmethodheight . "'); return false\" class=\"$menuclass\" " . $id . ">" . $mitem->name . "</a>\n";
         break;
         }

_________________
http://www.Galaxi-Designs.com


Top
 Profile  
 
PostPosted: Mon Apr 12, 2010 7:32 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Feb 22, 2008 3:34 am
Posts: 6
Is there any update on this? I am having similiar issues as crudi. I have followed this thread to the letter, and triple checked my code. No matter what options I select it just opens it up in a new window without navigation. I have jcemediabox installed using jcepopup as the class. I have gotten lightbox to work fine in my articles but I cannot get it to work properly in a menu. I also tried with both pieces of code for Case2. Using joomla 1.5.15


Top
 Profile  
 
PostPosted: Mon Apr 12, 2010 7:53 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Feb 25, 2010 1:46 pm
Posts: 10
The author made it working on my test site but only in the top menu. Perhaps it has also sthg. to do with the module or css settings...


Top
 Profile  
 
PostPosted: Mon Apr 12, 2010 7:54 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Feb 22, 2008 3:34 am
Posts: 6
Do you happen to know what he did to get it working on your site? I only need it for the top menu, so if thats all that works thats fine by me haha.


Top
 Profile  
 
PostPosted: Thu May 20, 2010 8:55 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu May 20, 2010 8:53 pm
Posts: 1
I added these links to the exact files and had no luck? the Menu Items (Edit) show the parameters but they don't work???


Top
 Profile  
 
PostPosted: Sun May 23, 2010 2:33 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun May 23, 2010 2:31 pm
Posts: 1
I am a novice with joomla but I can not cope with this alteration Help me to somehow convert the seat just a few days and do not know where my mistakes. I have version 1.5.15 and I do not mean to me is very anxious to start this.
Not open to him in the specified size

Image

Help


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 28 posts ] 



Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group