It appears the problem is from masking access to the control panel. To fix this, there are three things/calls that need to be changed. Unfortunately, one of those is in an externally linked Javascript file, making that sort of tough. I have it working in a masked control panel by updating the following:
mcp.selecteditems.php Around line 277, change:
$r .= '
<scr1pt type="text/javascript" src="modules/selecteditems/ajax.js"></scr1pt>
<scr1pt type="text/javascript" src="modules/selecteditems/selecteditems.js"></scr1pt>
to:
$r .= '
<scr1pt type="text/javascript" src="'.PATH.'modules/selecteditems/ajax.js"></scr1pt>
<scr1pt type="text/javascript" src="'.PATH.'modules/selecteditems/selecteditems.js"></scr1pt>
All you’re doing there is adding the PATH constant (see this thread called How do I get the system folder name for a handy list, and directions on where to find that list in core) That helps all the javascript to load correctly. If only we were done there.
selecteditems.js The next call we need to fix is is unfortunately in selecteditems.js, which is one of the files called above. This is a plain ol’ javascript file, so I’m not sure the best way to change this. The line in questions is approximately 84:
var url = "modules/selecteditems/helper.selecteditems.php?" +
"get_query=OK&filter;="+document.forms[0].filter.value+
Right now I’ve hard-coded my domain and real system folder name in there, i.e.:
var url = "http://site.dev/myrealsystem/modules/selecteditems/helper.selecteditems.php?" +
"get_query=OK&filter;="+document.forms[0].filter.value+
Does anyone have a good idea how to call that helper from the javascript file if you’re masking access to the control panel? I was even thinking something kooky like trying to pass the actual system folder name to the JS file, sort of like scriptaculous loads the correct file(s) when you do “scriptaculous.js?load=effects”, maybe like this:
<scr1pt type="text/javascript" src="'.PATH.'modules/selecteditems/selecteditems.js?sys='.PATH.'"></scr1pt>
I’m probably making this harder than it needs to be though. Any ideas welcome here - not just for this project, but to help module makers make modules that are ready for use with masked as well as non-masked Control Panels.
UPDATE: UGH the forum stripped my script tags, darnitall. They showed up fine in the preview! Feature request: how about the preview throws a warning if it sees any script tags?
OK, I have a fix for the JS too.
mcp.selecteditems.php Around line 486 find this:
$r .= $DSP->form_c();
That is the closing tag for the form. Well add a hidden field, right above that line to pass to the JS file. Add this line:
$r .= $DSP->input_hidden('sysfolder', PATH);
which will output this on the page:
<div class='hidden'><input type='hidden' name='sysfolder' value='../yourrealsystemfolder/' /></div>
selecteditems.js Around line 84, change this line:
var url = "modules/selecteditems/helper.selecteditems.php?" +
to:
var url = document.forms[0].sysfolder.value+"modules/selecteditems/helper.selecteditems.php?" +
That will prepend your real system folder name to this string.
This is working for me on my current site, where I have the CP masked. I’m not sure it’s working 100% though as I don’t know if it is supposed to remove your selections from the left side after selecting them…it doesn’t seem to be doing that.
Here is a new version of the SelectedItems module. It should fix the bugs noted above, and seems to work with a masked Control Panel like Ryan was trying to achieve above.
Let me know of any problems…
An upgrade should work fine, but this new version uses fewer files so you I’d recommend deleting the contents of the existing system/modules/selecteditems folder first, rather than just overwriting it.
Edit: Please see the Selected Items page to download current version
Thanks for this, Andrew. I wonder if there is a best practice for developing modules,etc which keeps in mind that the Control Panel can be masked. I was just emailing Leevi Graham on this subject as well. Thanks again, and I’ll let you know if I come upon any problems with this.
Seems to be working great. I do have one question - can “Status” be used as another search filtering criteria? I selected 5 entries for ordering, and the entries tag where they’re being output looks like this (note status is a custom one):
{exp:selecteditems name="{segment_1}"}
{exp:weblog:entries weblog="brokers" entry_id="{selecteditems_id}" category="{embed:category_id}"
dynamic="off" status="Broker" category_group="1" orderby="selecteditems"}
...the output...
Now, what I didn’t realize was that one of the five brokers in the list was set to “Closed”. When his name is in the selecteditems list, the page throws this error:
Notice: Undefined index: 28 in
/home/server/public_html/site/system/extensions/ext.selected_items.php on line 135
and the rest of the output of the page is messed up after where he is supposed show up. The problem is, my entries tag is set to only show one status - not closed entries. Removing him from the list allows the page to render properly with no errors. Do I need to set status as an entries parameter when using selecteditems?
I just upgraded to 1.2 version and it does not load any entries in the left panel.
I disabled module / ext and uploaded new files. I re-enabled module and ext. Went to test the module and it does not load weblog entries in the module area – it just says “loading…” and that’s it.
I’ve got EE 1.6.2 install.
–
I’d be happy to let the developer login to my EE install and take a look if that is helpful. Just let me know.
Also, I was wondering if it would be possible for me to be able to hack the module so that it put the date format prior to the Entry title when it lists it in the module?
I’ve done this with related content drop downs in the publish page entry forms. It would be helpful if I could see at a glance just that days new entries and know when I search for something what is from the current day and what isn’t.
Getting a weird problem with other users besides myself who are also Super Admins. They’re not getting any population of entries - although if I log in as them I get entries populating the list. I asked the other user who was having the problem (in FF) to show the error console, and I’ve attached pics. Look like the issue is with this line:
// Establish the connection to the server
xml.send();
We’re both using Firefox, and we’re both logged in as the same user (from two different locations) - the only difference is, I can see the entries on the left and he can’t. Seems like everyone else who is a Super Admin can’t get items to populate, but I can! Any ideas about this? I do have the 1.2 version installed.
I don’t think they’re getting a “Failed” message - it just continues to say “Loading” next to the Get Entries button.
I should also note that at least on my template, I could not get the selecteditems_switch to work correctly. I previously had it working with a regular switch statement (before the client wanted to custom order things…). The switch:
<div class="property{switch='| even| lower| even lower'}">
Over the loop that outputs:
<div class="property">
<div class="property even">
<div class="property lower">
<div class="property even lower">
Trying that same switch with selected items:
<div class="property{selecteditems_switch='| even| lower| even lower'}">
Didn’t output the switch statements. The workaround was to do this for now:
{if selecteditems_count == '1'}
<div class="property">
{if:elseif selecteditems_count == '2'}
<div class="property even">
{if:elseif selecteditems_count == '3'}
<div class="property lower">
{if:else}
<div class="property even lower">
{/if}
I’ve identified to ‘issues’:
1) It does not work on Internet Explorer! (I missed some javascript out of the file - whoops!)
2) The module uses AJAX, and AJAX can only make calls back to the current domain. As the module builds the AJAX url from EE’s settings it can sometimes be trying to access AJAX ‘illegally’. For example, if you access the Control Panel at http://mysite.com/ but EE is set up with http://www.mysite.com/ the AJAX call will fail.
Andrew, I’ll reinstall the module later today and test again but I was using Firefox and was consistent with using the full URL (www.domain.com) in logging in and where EE was set up. If you want to access my install later today to check out first hand the problem let me know. Thanks for looking into this issue!
Rob
I’ve attached a new version that should fix the bugs with IE6 and Firefox.
For those anyone interested, the AJAX call was failing only on versions of Firefox that did not have the Firebug extension installed. (Firefox without Firebug requires the XMLHTTPRequest.send() to have a parameter even if it is null, so changing the line xml.send() to xml.send(null) fixed the bug).
Thanks to Rob and Ryan for the help with this.
This version also add rudimentary support for the Multiple Site Manager, so different sites can now have different lists.
Edit: Please see the Selected Items page to download current version
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.