spudnukem
Joined: 18 Apr 2008
Posts: 3
Posted: 2008-04-18 02:35
Back to top
Reply with quote
|
I used the following to put a graphical button into the add/edit page to allow me to select images/ assets to input into the editing page.
$opts['fdd']['image'] = array(
'name' => 'Image',
'escape' => false,
'select' => 'T',
'maxlen' => 99,
'sort' => true
);
$opts['fdd']['image']['help'] = 'Select Image to appear with event : <a href=JavaScript:void(0); onclick=window.open("imageselector.php?e=PME_data_image&locus=artists","SelectImage","height=300,width=500,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no")><img src="../nimg/getimage.png" width=16 height=16 border=1></a>';
$opts['fdd']['image']['URL'] = 'javascript:popUp("../../images/artists/$value")';
$opts['fdd']['image']['URLdisp'] = '<img src="../../images/artists/$value" width=50 height=50 border=1/>';
The call opened a window which passed back the asset used via window.opener code ie if the image field is call 'blobby' then it was just PME_data_blobby.value = etc etc . Hope it helps someone.
|
lupker
Joined: 17 Apr 2008
Posts: 5
Posted: 2008-04-19 19:49
Back to top
Reply with quote
|
This works very well for me to open a javscript in a new window. But how can I pass the variable selected in the popup into the MPE field?
By the way: what script did you use for this imageselector ? Would like to use it too!
Thanks!
Gr,
Mark
|
spudnukem
Joined: 18 Apr 2008
Posts: 3
Posted: 2008-04-19 21:45
Back to top
Reply with quote
|
this bit sends which gallery to look at (locus) and the element on the opening page (e=PME_data_XXX)
imageselector.php?e=PME_data_image&locus=artists
and the image selector code is;
<?php
echo "<font face='Verdana,Geneva,Arial,Helvetica,sans-serif' size='1' color='#808080'><strong>THE MANGLER<SUP><FONT SIZE='1'>TM</FONT></SUP></strong> Source folder >> ".strtoupper($_GET['locus'])."</font><hr>";
$pathused = "../../images/".$_GET['locus'];
$formelement = $_GET['e'];
$handle=opendir($pathused);
$strSought1 = "jpg";
$strSought2 = "gif";
$strSought3 = "png";
$imgCount = 0;
while ($file = readdir($handle))
{
if ($strSought1 == substr($file, -3) || $strSought2 == substr($file, -3) || $strSought3 == substr($file, -3))
{
$imgCount = $imgCount + 1;
}
}
closedir($handle);
if ($imgCount != 0)
{
$handle=opendir($pathused);
$perRow = 5;
$numRows = $imgCount/$perRow;
$imgNum = 0;
echo "<table border=\"0\" cellspacing=2>";
while (false !== ($file = readdir($handle)))
{
if ($strSought1 == substr($file, -3) || $strSought2 == substr($file, -3) || $strSought3 == substr($file, -3))
{
$imgNum++;
echo "<td><a href=\"javascript:void();\" onclick=\"window.opener.document.forms[0].$formelement.value='$file'; window.close();\" ><img src=\"".$pathused."/".$file."\" height=\"35\" width=\"45\" border=\"1\"></a>";
//modulus (%) $a % $b remainder of $a divided by $b
if ($imgNum%$perRow)
{
echo "</td>";
}
else
{
echo "</td></tr><tr>";
}
}
}
closedir($handle);
echo "</table>";
}
?>
really basic gallery but shows where the link to add the image name is.
All the best
|
lupker
Joined: 17 Apr 2008
Posts: 5
Posted: 2008-04-20 00:24
Back to top
Reply with quote
|
Your code helped me a lot to make my colorpicker.
You can find my comments on this here:
http://opensource.platon.sk/forum/projects/viewtopic.php?p=15470#15470
Gr,
Mark
|
kally
Joined: 05 Jan 2005
Posts: 14
Posted: 2008-10-13 00:22
Back to top
Reply with quote
|
Great Solution! I've been wanting to do this for quite awhile, but never tackled it. I've been using a drop down with a list of file names generated with PHP - but seeing the thumbnails is so much better for some sites.
I have everything working to a point. On my PME page, I have the link that opens the thumbnail popup, the popup DOES open with all of the thumbnails displayed, but when I click on a thumbnail nothing happens.
My PME code is:
| Code: |
$opts['fdd']['thumb'] = array(
'name' => 'Thumbnail Image',
'escape' => false,
'select' => 'T',
'required' => true,
'sort' => true
);
$opts['fdd']['thumb']['help'] = 'Select thumbnail image: <a href=JavaScript:void(0); onclick=window.open("imageselector.php?e=PME_data_thumb&locus=tn","SelectImage","height=300,width=500,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no")>click here</a>';
$opts['fdd']['thumb']['URL'] = 'javascript:popUp("../img/jewelry/tn/$value")';
$opts['fdd']['thumb']['URLdisp'] = '<img src="../img/jewelry/tn/$value" width=50 height=50 border=1/>';
|
for the imageselector.php file, i used your exact code - just changing the pathused variable. So, I'm seeing the thumbnails and everything appears to be working okay. But the popup does NOT close when a thumbnail is clicked, so I have to close the window using the red X and nothing is passed to PME.
I suppose I am missing something simple - can you help?
Thak you! Kally
|
lupker
Joined: 17 Apr 2008
Posts: 5
Posted: 2008-10-13 09:07
Back to top
Reply with quote
|
Hi Kally,
I had the same problem, not sure what i've changed (time ago), but as i can see in the working version is this code (in the php my edit):
| Code: |
$opts['fdd']['cover'] = array(
'name' => 'Cover',
'select' => 'T',
'maxlen' => 255,
'trimlen' => 20,
'sort' => true
);
$opts['fdd']['cover']['help'] = 'Select Image : <a href=JavaScript:void(0); onclick=window.open("imageselector/imageselector.php?e=PME_data_cover&locus=images","SelectImage","height=300,width=500,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no")>click here</a>';
|
This is all. So no extra javascript:
| Code: |
$opts['fdd']['thumb']['URL'] = 'javascript:popUp("../img/jewelry/tn/$value")';
$opts['fdd']['thumb']['URLdisp'] = '<img src="../img/jewelry/tn/$value" width=50 height=50 border=1/>';
|
And the imageselector.php file look like this:
| Code: |
<?php
echo "<font face='Verdana,Geneva,Arial,Helvetica,sans-serif' size='1' color='#808080'><strong>Image Selector<SUP><FONT SIZE='1'>TM</FONT></SUP></strong> Source folder >> ".strtoupper($_GET['locus'])."</font><hr>";
$pathused = "../../".$_GET['locus'];
$formelement = $_GET['e'];
$handle=opendir($pathused);
$strSought1 = "jpg";
$strSought2 = "gif";
$strSought3 = "png";
$imgCount = 0;
while ($file = readdir($handle))
{
if ($strSought1 == substr($file, -3) || $strSought2 == substr($file, -3) || $strSought3 == substr($file, -3))
{
$imgCount = $imgCount + 1;
}
}
closedir($handle);
if ($imgCount != 0)
{
$handle=opendir($pathused);
$perRow = 5;
$numRows = $imgCount/$perRow;
$imgNum = 0;
echo "<table border=\"0\" cellspacing=2>";
while (false !== ($file = readdir($handle)))
{
if ($strSought1 == substr($file, -3) || $strSought2 == substr($file, -3) || $strSought3 == substr($file, -3))
{
$imgNum++;
echo "<td><a href=\"javascript:void();\" onclick=\"window.opener.document.forms[0].$formelement.value='$file'; window.close();\" ><img src=\"image.php?image=".$pathused."/".$file."&percent=33\" border=\"0\"></a>";
// echo "<td><a href=\"javascript:void();\" onclick=\"window.opener.document.forms[0].$formelement.value='$file'; window.close();\" ><img src=\"".$pathused."/".$file."\" border=\"0\"></a>";
//modulus (%) $a % $b remainder of $a divided by $b
if ($imgNum%$perRow)
{
echo "</td>";
}
else
{
echo "</td></tr><tr>";
}
}
}
closedir($handle);
echo "</table>";
}
?>
|
Hope this works for you ?
gr,
Mark
|
kally
Joined: 05 Jan 2005
Posts: 14
Posted: 2008-10-13 20:39
Back to top
Reply with quote
|
Well, I found a solution that works for me. The js error I was getting was:
'window.opener.document.forms.0.PME_data_thumb' is null or not an object.
So I read as much as I could on that type of error, then used the Firefox web developer tools to view the form information on the PME page. I noticed that the name of the element for thumb was 'thumb' not 'PME_data_thumb' so I changed the line on my PME page to read:
| Code: |
$opts['fdd']['thumb']['help'] = 'Select thumbnail image: <a href=JavaScript:void(0); onclick=window.open("imageselector.php?e=thumb&locus=tn","SelectImage","height=300,width=500,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=yes")>click here</a>';
|
That worked! Maybe PME_data prefix is for a different version of PME than I am using.
Anyway, thanks for the script. It is just what I needed. It should be quite easy to go the next step and integrate an image manager.
Thanks again!
Kally
|
|
Post new topic
Reply to topic
|
|