Advanced search  

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

Pages: [1]   Go Down

Author Topic: just getting the filename via $objCpm ?  (Read 9447 times)

0 Members and 1 Guest are viewing this topic.

Jost

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
just getting the filename via $objCpm ?
« on: December 03, 2006, 11:43:24 pm »

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

Jost

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: just getting the filename via $objCpm ?
« Reply #1 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.
Code: [Select]
<?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); ?> )
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: just getting the filename via $objCpm ?
« Reply #2 on: December 04, 2006, 10:06:38 pm »

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.
Code: [Select]
<?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:


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

YMMV as I did not sytax check it



Logged
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

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: just getting the filename via $objCpm ?
« Reply #3 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.
 
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: just getting the filename via $objCpm ?
« Reply #4 on: December 05, 2006, 04:25: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?
Logged
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

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: just getting the filename via $objCpm ?
« Reply #5 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']
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: just getting the filename via $objCpm ?
« Reply #6 on: December 05, 2006, 08:11:42 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...

Code: [Select]
($objCpm->cpm_viewRandomMediaFrom ( 1, 1, "album=112",$options))[0]['pFilename'];
if that does not work, just assign the output, then use it...

Code: [Select]
$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.




Logged
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

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: just getting the filename via $objCpm ?
« Reply #7 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
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: just getting the filename via $objCpm ?
« Reply #8 on: December 05, 2006, 10:06:42 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. 
Logged
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

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: just getting the filename via $objCpm ?
« Reply #9 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:
Code: [Select]
  <div style="background-image:url({CUSTOM_HEADER})">
  <div id="logo">
</div>
</div>
now the custom header contains the following:
Code: [Select]
<?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(); ?>
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: just getting the filename via $objCpm ?
« Reply #10 on: December 05, 2006, 10:56:11 pm »

Thanks very much for the support.
On my indexpage I have included the following for the header:
Code: [Select]
  <div style="background-image:url({CUSTOM_HEADER})">
  <div id="logo">
</div>
</div>
now the custom header contains the following:
Code: [Select]
<?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.






Logged
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

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: just getting the filename via $objCpm ?
« Reply #11 on: December 05, 2006, 11:04:52 pm »

oh come on you really expect me to...oh wait - you were absolutely right there. thanks a lot.
Logged
Pages: [1]   Go Up
 

Page created in 0.026 seconds with 19 queries.