Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 6.9
Author Message
sqzdog
Involved
Involved



Joined: Sep 22, 2003
Posts: 252

PostPosted: Fri Nov 07, 2003 7:54 pm Reply with quote

Would like to post a weekly photo in a block for our local dog pound. Can anyone tell me how to do this?
 
View user's profile Send private message Send e-mail
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri Nov 07, 2003 8:22 pm Reply with quote

Code:
<?php


/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

if (eregi("block-Picture_Block.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

$content = "<center><img src=\"images/Wire-Fox-Terrier.jpg\" noborder></center>";

?>
Save the file to blocks/block-Picture_Block.php. You could also not make it a file and just make it an in-line block in the Block Administration panel. This assumes that images/Wire-Fox-Terrier.jpg is the location and name of your picture. You can, of course, add any valid options to the IMG tag.
 
View user's profile Send private message
sqzdog







PostPosted: Sat Nov 08, 2003 7:29 am Reply with quote

Ok, I got that working good. Thanks for the tip. Now, If I want to add some text below it, info about the animal, etc, with a link to the pound website, how is that done?
 
CodyG
Life Cycles Becoming CPU Cycles



Joined: Jan 02, 2003
Posts: 714
Location: Vancouver Island

PostPosted: Sat Nov 08, 2003 8:12 pm Reply with quote

try ...

Code:


if (eregi("block-Picture_Block.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

$content = "<center><img src=\"images/Wire-Fox-Terrier.jpg\" noborder><br>this is some text</center>";


I love the way php and html work together. I guess it could be so elegant or it it could be a real plate of spagetti.
 
View user's profile Send private message
mikem
New Member
New Member



Joined: Sep 23, 2003
Posts: 15

PostPosted: Sat Nov 08, 2003 8:25 pm Reply with quote

Justa tip, but this nice little tool comes in handy by Disipal when making your own blocks and converting html to php.
[ Only registered users can see links on this board! Get registered or login! ]
 
View user's profile Send private message
Raven







PostPosted: Sat Nov 08, 2003 8:35 pm Reply with quote

Personally, I think those tools cause unnecessary overhead and confusion. It is much simpler and much more powerful to use the WHEREDOC syntax. That way, you don't have any quoting issues at all. You develop your html/css/javascript and get it working. Then, you simply drop it into the WHEREDOC block! And, you can use PHP variables too. What a bonus. So the code above becomes

$content = <<<_MYCODE_
<center><img src="images/Wire-Fox-Terrier.jpg" noborder><br>this is some text</center>
_MYCODE_;

Obviously a one line is not indicative of the savings. Search in my forums and at NC to see all my posts on WHEREDOC.
 
CodyG







PostPosted: Sun Nov 09, 2003 11:04 am Reply with quote

exactly ... seems to me that overcoming the nuke learning curve for those who already do html is getting their html into the php. Had I known about WHEREDOC, (also HEREDOC?, php manual), I would have saved myself a zillion hours.
 
sqzdog







PostPosted: Sun Nov 09, 2003 11:32 am Reply with quote

I followed the original code that Cody G suggested and it worked great. I tried to place a link to this dog pound within the text and it wouldn't work. Here is an example:

Quote:

if (eregi("block-Picture_Block.php",$_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}

$content = "<center><img src=\"images/Wire-Fox-Terrier.jpg\" noborder><br>this is some text that includes a link<a href="http:dogpound.com">Dog Pound</a></center>";


It have me a parse error or something. It works fine as long as I don't try to put a link in the text. Any ideas?
 
Raven







PostPosted: Sun Nov 09, 2003 11:35 am Reply with quote

Quote:

$content = "<center><img src=\"images/Wire-Fox-Terrier.jpg\" noborder><br>this is some text that includes a link<a href="http:dogpound.com">Dog Pound</a></center>";
You have not escaped quotes w/i quotes with a \ . Try this
Code:
$content = "<center><img src=\"images/Wire-Fox-Terrier.jpg\" noborder><br>this is some text that includes a link<a href=\"http:dogpound.com\">Dog Pound</a></center>";
 
CodyG







PostPosted: Sun Nov 09, 2003 11:53 am Reply with quote

It is that annoying escaping quotes that makes Raven's solution so elegant. Do try Raven's idea too.
 
sqzdog







PostPosted: Sun Nov 09, 2003 1:22 pm Reply with quote

No, because I have no idea what that is. Is it a program or something?
 
sqzdog







PostPosted: Sun Nov 09, 2003 7:40 pm Reply with quote

OK, Cody I tried your script above, but the link when clicked, takes me to [ Only registered users can see links on this board! Get registered or login! ]
 
Raven







PostPosted: Sun Nov 09, 2003 7:43 pm Reply with quote

I never noticed that you still have a syntax error in your code. You have http:dogpound.com

it should be [ Only registered users can see links on this board! Get registered or login! ]
 
sqzdog







PostPosted: Sun Nov 09, 2003 7:45 pm Reply with quote

oh, yes it does have the // in it.

Quote:
[ Only registered users can see links on this board! Get registered or login! ]
 
Raven







PostPosted: Sun Nov 09, 2003 7:48 pm Reply with quote

Well, it doesn't in any of your previous posts so that seemed like an obvious one. If it does and this is your code, it should work
Code:
$content = "<center><img src=\"images/Wire-Fox-Terrier.jpg\" noborder><br>this is some text that includes a link<a href="http://dogpound.com">Dog Pound</a></center>"; 

 
sqzdog







PostPosted: Sun Nov 09, 2003 8:12 pm Reply with quote

Here is the entire code. It still ain't working.

Quote:

if (eregi("block-Picture_Block.php",$_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}

$content = "<center><img src=\"images/spca.jpg\" noborder><br><b>Patches</b>, a golden lab X, female, about 2.5 years old and weighs about 45 lbs.<br>Visit the<a href="http://cstone.net/~fspca">Fluvanna SPCA</a></center>";

?>
 
Raven







PostPosted: Sun Nov 09, 2003 8:14 pm Reply with quote

You still have not entered your quotes w/i quotes Rolling Eyes

All quotes w/i quotes MUST be prefaced with a \
Code:
$content = "<center><img src=\"images/spca.jpg\" noborder><br><b>Patches</b>, a golden lab X, female, about 2.5 years old and weighs about 45 lbs.<br>Visit the<a href=\"http://cstone.net/~fspca\">Fluvanna SPCA</a></center>";
 
sqzdog







PostPosted: Sun Nov 09, 2003 8:19 pm Reply with quote

Great, now i get what you mean about the within quotes having the \

Thanks Gaylen
 
sqzdog







PostPosted: Sun Nov 09, 2003 9:49 pm Reply with quote

Fixed, thanks!
 
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 6.9

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©