Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Tip: How to add CpmFetch into Html  (Read 6411 times)

0 Members and 1 Guest are viewing this topic.

emjay_smitten

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Tip: How to add CpmFetch into Html
« on: January 27, 2010, 09:40:31 am »

I wanted to put 1 image into www.mywebpage.html that is like an intro for my site http://www.haiticontacts.com. It took me one whole day to find out why it did not show, as many people say it only works on .php

Finally this morning I figured it out and is actually quite easy.

In your webhost most of the time you can get access to apache handlers. If you can here is what you need to do:

for example click on Add Apache Handler.
Then put as Apache handler AddHandler application/x-httpd-php5
Then put .html .htm as the type of webpage that need to handle the php.

It will tell your webhost server to handle php in html pages. If you cannot you can make a file called .htaccess in notepad. Add the suggested line in there and upload into the root of your hosing account.

Then in www.mywebpage.html I add:

<?php
  include "./pictures/cpmfetch/cpmfetch.php";
  $objCpm = new cpm("./pictures/cpmfetch/cpmfetch_config.php");
  $options = array ('imagesize' => 'large' );
  $objCpm-> cpm_viewLastAddedMedia(1,1, $options) ;
  $objCpm-> cpm_viewLastAddedMedia(1,4) ;
  $objCpm-> cpm_close();
?>

This will show 1 image in large from the last added media.
And 4 thumbs underneath.

Now all I need to do is get rid of the border (this I see in the forum somewhere) , do some layout and find out how to get a random image instead of LastAddedMedia.

I hope this can help somebody. But for now, this sweet program is doing what it says!!! TOP
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Tip: How to add CpmFetch into Html
« Reply #1 on: January 27, 2010, 12:16:53 pm »

In other words, you instructed your webserver to parse all HTML files on your server with the PHP parser. Of course you can do that, but there are several reasons why you shouldn't:
  • Processing of plain HTML pages will get slower
  • Resources consumption on your server will increase
  • Your webhost might shake the naughty finger at you

You could do the same on your client operating system as well and instruct it to fire up your word processor when a .txt file is clicked on. You just burn resources that way. But if that makes you happy, that's fine for us. Just a recommendation at others not to do that. Additionally, most webhosts won't allow you to do what you're doing.

Instead of doing what you did I suggest to undo your edit in your .htaccess file and to rename the index file in your webroot (the file that you incorrectly refered to as
www.mywebpage.html
, but that actually is named index.html, i.e. http://www.haiticontacts.com/index.html) to index.php
Use your favorite FTP app to accomplish that. Takes less then a minute.
That should be all it takes. Ta-da.
« Last Edit: January 27, 2010, 12:22:18 pm by Joachim Müller »
Logged

emjay_smitten

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: Tip: How to add CpmFetch into Html
« Reply #2 on: January 27, 2010, 03:55:17 pm »

Hi thanks for the tip. I tried that before and did not work but now it did. I just wanted to demonstrate that it can be done.

I do not have .htaccess in my webhostfolder. I just used the appache handlers to process php on html. You think I have to delete them to?

I know this will be off-topic so this will be the last of it. I thank you anyway for your response  ;)

Oh, you want me to close the topic or do you?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Logged

idosha

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 27
Re: Tip: How to add CpmFetch into Html
« Reply #4 on: July 10, 2010, 03:38:11 pm »

Another option is to use a .shtml website and to call a .php page using SSI <!--#include virtual="/ssi/lastadded.php" --> I personally use this solution myself.
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me
[Closed]: Re: Tip: How to add CpmFetch into Html
« Reply #5 on: July 10, 2010, 05:35:06 pm »

But why? Simply do as Joachim suggests.

Anyway, closing and locking.
Logged
It is a mistake to think you can solve any major problems just with potatoes.
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.