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: CpmFetch: view...MediaByKeyword  (Read 15644 times)

0 Members and 1 Guest are viewing this topic.

cornetchap

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 1
    • Wiley's World
CpmFetch: view...MediaByKeyword
« on: August 31, 2005, 01:43:52 pm »

Hi all.

 I've been using the CpmFetch software for a while now on a couple of websites I run and I thought I'd share some mods I've made that you may be interested in, namely:

  • cpmViewRandomImagesByKeyword
  • cpmViewLastAddedImagesByKeyword

and their corresponding DAO functions.

Ideally I was going to do these functions by keywords (note the 's') but couldn't be faffed figuring out how to do this sensibly in SQL.

Note that these are modifications to an old version of CpmFetch so may not be compatible with the latest version.

Changes to coppermine.php are:
Code: [Select]
  /**
  * Displays random images based on keyword
  *
  * This will generate a table and populate it with the random media and style
  * it based on the entries in the style hash. The number of photos returned
  * matches the number of rows multiplied by the number of columns.
  *
  * @param int $rows The number of rows desired in the output
  * @param int $columns The number of columns desired in the output
  * @param array $keywords An array of keyword strings to match
  * @param array $options Optional, configuration options
  *
  */
  function cpm_viewLastAddedMediaByKeyword($keyword, $rows, $columns, $options="") {
    if (is_array($options) && version_compare(phpversion(),'4.2.0')) {
      $options = array_change_key_case($options, CASE_LOWER);
    }

    $resultset = $this->cpm->getLastAddedImageByKeyword($keyword,
                                                        $rows * $columns);
    print $this->createTable($resultset, $rows, $columns, $options);
  }

  /**
  * Displays random images based on keyword
  *
  * This will generate a table and populate it with the random media and style
  * it based on the entries in the style hash. The number of photos returned
  * matches the number of rows multiplied by the number of columns.
  *
  * @param int $rows The number of rows desired in the output
  * @param int $columns The number of columns desired in the output
  * @param array $keywords An array of keyword strings to match
  * @param array $options Optional, configuration options
  *
  */
  function cpm_viewRandomMediaByKeyword($keyword, $rows, $columns, $options="") {
    if (is_array($options) && version_compare(phpversion(),'4.2.0')) {
      $options = array_change_key_case($options, CASE_LOWER);
    }

    $resultset = $this->cpm->getRandomImageByKeyword($keyword,
                                                     $rows * $columns);
    print $this->createTable($resultset, $rows, $columns, $options);
  }

Changes to coppermine_dao.php are:

Code: [Select]
  var $sqlPictureSelect = ' p.filepath, p.filename, p.aid, p.filesize, p.title, p.caption, p.owner_name, p.ctime, p.hits, p.pid ';

  // Returns last added image based on a keyword search
  function getLastAddedImageByKeyword($keyword = "", $count) {
    $retval = "";

    if (is_numeric($count) && !empty($keyword)) {
      $sqlcode = "SELECT " . $this->sqlPictureSelect . " FROM " . $this->cpm_table_prefix . "pictures as p where locate('" . $keyword . "', p.keywords) <> 0 and p.approved='YES' order by p.ctime desc limit 0,$count";
      $retval = $this->dbExecuteSql($sqlcode);
    }

    return($retval);
  }

  // Returns a random image based on a keyword search
  function getRandomImageByKeyword($keyword = "", $count) {
    $retval = "";

    if (is_numeric($count) && !empty($keyword)) {
      $sqlcode = "SELECT " . $this->sqlPictureSelect . " FROM " . $this->cpm_table_prefix . "pictures as p where locate('" . $keyword . "', p.keywords) <> 0 and p.approved='YES' order by rand() limit $count";
      $retval = $this->dbExecuteSql($sqlcode);
    }

    return($retval);
  }
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: CpmFetch: view...MediaByKeyword
« Reply #1 on: August 31, 2005, 11:34:41 pm »

Hi all.

 I've been using the CpmFetch software for a while now on a couple of websites I run and I thought I'd share some mods I've made that you may be interested in, namely:

  • cpmViewRandomImagesByKeyword
  • cpmViewLastAddedImagesByKeyword

and their corresponding DAO functions.



Hah, looks like I made it to the big time when people are modding my stuff :)

Just a matter of time before the woman, money and wine starts rolling in...


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

Anke

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: CpmFetch: view...MediaByKeyword
« Reply #2 on: December 27, 2005, 03:59:09 pm »

This is exactly what I was looking for... Unfortunately I can't get it to work in cpmfetch 1.6.2
Has anyone done that already? Or can tell me in which version it works?
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: CpmFetch: view...MediaByKeyword
« Reply #3 on: December 28, 2005, 08:38:00 am »

This is exactly what I was looking for... Unfortunately I can't get it to work in cpmfetch 1.6.2
Has anyone done that already? Or can tell me in which version it works?

Yeah, some of the code changed.  This is slated to be included in one of the future releases of cpmfetch (with the authors blessing).  Sometime in the 1.7 development chain (which has started).

Will be announced on the mailing list at http://cpmfetch.fistfullofcode.com and in the main forum.



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

Anke

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: CpmFetch: view...MediaByKeyword
« Reply #4 on: December 28, 2005, 12:52:21 pm »

Thanks for the info :)
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: CpmFetch: view...MediaByKeyword
« Reply #5 on: April 02, 2007, 08:37:23 pm »

Thanks for the info :)

This type of functionality has been included in CpmFetch 1.9.11 and greater.  It allows for searching the keywords, captions and / or descriptions for keywords.

See http://cpmfetch.fistfullofcode.com


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

hdelange

  • Coppermine newbie
  • Offline Offline
  • Posts: 12
Re: CpmFetch: view...MediaByKeyword
« Reply #6 on: May 01, 2007, 12:30:42 am »

i have downloaded the latest version 2.0.0 and i will use the option media selected by keywords and that works great.

$objCpm->cpm_viewRandomMediaFrom("cat=2:album=526:keyword=anab",4, 5, $options);

now my question i also want to make a selection of the text that stays in the descrition, is that possible?

ik tried it to change keyword to description, but this does not work.

$objCpm->cpm_viewRandomMediaFrom("cat=2:album=526:description=anab",4, 5, $options);


is this one option?

greatz,

Henk
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 20 queries.