Menu External Link Popup Width and Height Modification

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Sat Jan 23, 2010 6:34 pm

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: Select all

<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: Select all

$mitem->name = stripslashes(htmlspecialchars($mitem->name));


ADD

Code: Select all

$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: Select all

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.

basher91260
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jan 25, 2010 8:28 pm

Re: Menu External Link Popup Width and Height Modification

Postby basher91260 » Mon Jan 25, 2010 8:34 pm

This is still not working for me :S

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Mon Jan 25, 2010 8:56 pm

You have Joomla 1.5.15?

basher91260
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jan 25, 2010 8:28 pm

Re: Menu External Link Popup Width and Height Modification

Postby basher91260 » Mon Jan 25, 2010 9:39 pm

Yeh, I have version 1.5.15

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Tue Jan 26, 2010 2:37 pm

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.

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Thu Feb 25, 2010 1:51 pm

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:

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...

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Thu Feb 25, 2010 2:01 pm

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?

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Thu Feb 25, 2010 2:08 pm

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.

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Thu Feb 25, 2010 2:18 pm

Code: Select all

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.

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Tue Mar 02, 2010 9:31 am

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: Select all

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


Case II:

Code: Select all

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


CaseIII:

Code: Select all

<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??

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Tue Mar 02, 2010 2:41 pm

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.

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Tue Mar 02, 2010 4:02 pm

Here my code in modules/mod_mainmenu/legacy.php

Code: Select all

// 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;
}

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Tue Mar 02, 2010 4:09 pm

Ok so you also added this to that file where I specified (make sure):

Code: Select all

$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: Select all

<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>

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Tue Mar 02, 2010 4:18 pm

I think so:

Code: Select all

// 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: Select all

<?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>

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Tue Mar 02, 2010 4:33 pm

Well do you mind checking? All that code is needed for it to work.

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Tue Mar 02, 2010 5:00 pm

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?

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Wed Mar 03, 2010 9:21 pm

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.

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Thu Mar 04, 2010 9:15 am

I attached a link where you can see the settings in the backend:

external_link.jpg


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

Code: Select all

<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.

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Thu Mar 04, 2010 2:33 pm

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.

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Thu Mar 04, 2010 3:22 pm

i know - but anywhere seems to be a mistake, but I cannot find it.

external_link.jpg


Code: Select all

<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.

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Thu Mar 04, 2010 3:32 pm

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.

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Thu Mar 04, 2010 3:42 pm

Yes - sounds good

GalaxiDesigns
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sat Aug 22, 2009 4:45 pm

Re: Menu External Link Popup Width and Height Modification

Postby GalaxiDesigns » Fri Mar 05, 2010 8:57 pm

Also Code Under CASE 2 above is now changed to:

Code: Select all

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;
         }

Todesengel
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Feb 22, 2008 3:34 am

Re: Menu External Link Popup Width and Height Modification

Postby Todesengel » Mon Apr 12, 2010 7:32 am

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

crudi
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Thu Feb 25, 2010 1:46 pm

Re: Menu External Link Popup Width and Height Modification

Postby crudi » Mon Apr 12, 2010 7:53 am

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...

Todesengel
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Feb 22, 2008 3:34 am

Re: Menu External Link Popup Width and Height Modification

Postby Todesengel » Mon Apr 12, 2010 7:54 am

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.

hymasd
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu May 20, 2010 8:53 pm

Re: Menu External Link Popup Width and Height Modification

Postby hymasd » Thu May 20, 2010 8:55 pm

I added these links to the exact files and had no luck? the Menu Items (Edit) show the parameters but they don't work???

Van Dzikens
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun May 23, 2010 2:31 pm

Re: Menu External Link Popup Width and Height Modification

Postby Van Dzikens » Sun May 23, 2010 2:33 pm

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.


Return to “Joomla! 1.5 Coding”

Who is online

Users browsing this forum: No registered users and 17 guests