just getting the filename via $objCpm ? just getting the filename via $objCpm ?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

just getting the filename via $objCpm ?

Started by Jost, December 03, 2006, 11:43:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jost

Is there a way just to receive the filename of a random file from the gallery?
Have been looking around here for a considerable amount of time and it just seems nowhere to find.
I also had a look into cfimageget but it just lead to a bit of confusion.   ???

Jost

all i would actually need is not to generate a table. With setReturnType I either get html or nothing.
All i want to retrieve is the actual filename.
<?php
include "../../cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gcj/cpg1410/");
$options = array( noimage => "",'imagesize' => 'large''subtitle' =>'albums/userpics/10001/%f' );
//$objCpm->cpm_viewRandomMediaFrom ( 1, 1, "album=112",$options);
?>

<div id="banner" background-img:url( <?php $objCpm->cpm_viewRandomMediaFrom 11"album=112",$options); ?> )

vuud

Quote from: Jost on December 04, 2006, 12:09:40 AM
all i would actually need is not to generate a table. With setReturnType I either get html or nothing.
All i want to retrieve is the actual filename.
<?php
include "../../cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gcj/cpg1410/");
$options = array( noimage => "",'imagesize' => 'large''subtitle' =>'albums/userpics/10001/%f' );
//$objCpm->cpm_viewRandomMediaFrom ( 1, 1, "album=112",$options);
?>

<div id="banner" background-img:url( <?php $objCpm->cpm_viewRandomMediaFrom 11"album=112",$options); ?> )




You need to set the resulttype to resultset (I think...)

That returns you an array of rows.  Each row contains an associative array of name => value pairs for that particular image.

Try putting this in your code somewhere (just to see it)...

<pre>
<?php print_r($objCpm->cpm_viewRandomMediaFrom( 1, 1, "album=112",$options));  ?>
</pre>

This will show you all the data that comes back.  Problem is that it will not return a full path to the image, well, a partial one maybe.

After that you need to modify your code to be something more like:



<?php print $objCpm->cpm_viewRandomMediaFrom 11"album=112",$options)[0]['keyname']; ?>


YMMV as I did not sytax check it



Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

Jost

thanks very much for the reply. Outputting the whole array works just fine, but I cant seem to get only the pFilename.

vuud

Quote from: Jost on December 05, 2006, 03:17:16 PM
thanks very much for the reply. Outputting the whole array works just fine, but I cant seem to get only the pFilename.


The something is off in the way I did this:

$objCpm->cpm_viewRandomMediaFrom ( 1, 1, "album=112",$options)[0]['keyname'];

Maybe the 0 should be a 1... I can never remember what language is what base.
And keyname gets changed... you know that part right?
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

Jost

this is what I get back:
Parse error: parse error, unexpected '[' in F:\server\minixampp\htdocs\gcj\cpg1410\themes\blix\header.php on line 13
so it seems as if he cant handle the part in the square brackets. I assumed keyname would be the needed attribute i.e. ['pFilename']

vuud

Quote from: Jost on December 05, 2006, 04:52:11 PM
this is what I get back:
Parse error: parse error, unexpected '[' in F:\server\minixampp\htdocs\gcj\cpg1410\themes\blix\header.php on line 13
so it seems as if he cant handle the part in the square brackets. I assumed keyname would be the needed attribute i.e. ['pFilename']

Maybe it does not like the order of precedence there...  Try this...

($objCpm->cpm_viewRandomMediaFrom ( 1, 1, "album=112",$options))[0]['pFilename'];

if that does not work, just assign the output, then use it...


$data = $objCpm->cpm_viewRandomMediaFrom ( 1, 1, "album=112",$options);
print $data[0]['pFilename'];  //or whatever you want to do with it


Not as elegant, but saves me the time of working it out for you, and you the time of learning php.




Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

Jost

argh this is getting messed up. I get the the output just fine, but it still wants to give me an error message saying:
Fatal error: Cannot redeclare class cpm in F:\server\minixampp\htdocs\gcj\cpg1410\cpmfetch\cpmfetch.php on line 33

vuud

Quote from: Jost on December 05, 2006, 09:50:35 PM
argh this is getting messed up. I get the the output just fine, but it still wants to give me an error message saying:
Fatal error: Cannot redeclare class cpm in F:\server\minixampp\htdocs\gcj\cpg1410\cpmfetch\cpmfetch.php on line 33

Post all your code.  I cannot see what you are doing from here. 
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

Jost

Thanks very much for the support.
On my indexpage I have included the following for the header:
  <div style="background-image:url({CUSTOM_HEADER})">
<div id="logo">
</div>
</div>

now the custom header contains the following:

<?php
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gcj/cpg1410/");
/*$options = array( noimage => "",'imagesize' => 'large', 'subtitle' =>'albums/userpics/10001/%f' );*/
$objCpm->cpm_setReturnType("resultset"); 
$data=$objCpm->cpm_viewRandomMediaFrom 11"album=112",$options);
?>

albums/userpics/10001/<?php print $data[0]['pFilename'];?>
<?php $objCpm->cpm_close(); ?>

vuud

Quote from: Jost on December 05, 2006, 10:13:49 PM
Thanks very much for the support.
On my indexpage I have included the following for the header:
  <div style="background-image:url({CUSTOM_HEADER})">
<div id="logo">
</div>
</div>

now the custom header contains the following:

<?php
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/gcj/cpg1410/");
/*$options = array( noimage => "",'imagesize' => 'large', 'subtitle' =>'albums/userpics/10001/%f' );*/
$objCpm->cpm_setReturnType("resultset"); 
$data=$objCpm->cpm_viewRandomMediaFrom 11"album=112",$options);
?>

albums/userpics/10001/<?php print $data[0]['pFilename'];?>
<?php $objCpm->cpm_close(); ?>


You didn't do something silly like have another include statement somewhere that is getting run in the same rendering...

comment out the include you have there... if that fixes it then you did something goofy like including it twice.






Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

Jost

oh come on you really expect me to...oh wait - you were absolutely right there. thanks a lot.