Author |
Message |
sqzdog
Involved


Joined: Sep 22, 2003
Posts: 252
|
Posted:
Fri Nov 07, 2003 7:54 pm |
|
Would like to post a weekly photo in a block for our local dog pound. Can anyone tell me how to do this? |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Fri Nov 07, 2003 8:22 pm |
|
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. |
|
|
|
 |
sqzdog

|
Posted:
Sat Nov 08, 2003 7:29 am |
|
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
|
Posted:
Sat Nov 08, 2003 8:12 pm |
|
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. |
|
|
|
 |
mikem
New Member


Joined: Sep 23, 2003
Posts: 15
|
Posted:
Sat Nov 08, 2003 8:25 pm |
|
|
|
 |
Raven

|
Posted:
Sat Nov 08, 2003 8:35 pm |
|
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

|
Posted:
Sun Nov 09, 2003 11:04 am |
|
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?, Only registered users can see links on this board! Get registered or login!), I would have saved myself a zillion hours. |
|
|
|
 |
sqzdog

|
Posted:
Sun Nov 09, 2003 11:32 am |
|
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

|
Posted:
Sun Nov 09, 2003 11:35 am |
|
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 thisCode:$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

|
Posted:
Sun Nov 09, 2003 11:53 am |
|
It is that annoying escaping quotes that makes Raven's solution so elegant. Do try Raven's idea too. |
|
|
|
 |
sqzdog

|
Posted:
Sun Nov 09, 2003 1:22 pm |
|
No, because I have no idea what that is. Is it a program or something? |
|
|
|
 |
sqzdog

|
Posted:
Sun Nov 09, 2003 7:40 pm |
|
|
|
 |
Raven

|
Posted:
Sun Nov 09, 2003 7:43 pm |
|
I never noticed that you still have a syntax error in your code. You have http:dogpound.com
it should be http://dogpound.com |
|
|
|
 |
sqzdog

|
Posted:
Sun Nov 09, 2003 7:45 pm |
|
oh, yes it does have the // in it.
|
|
|
|
 |
Raven

|
Posted:
Sun Nov 09, 2003 7:48 pm |
|
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 workCode:$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

|
Posted:
Sun Nov 09, 2003 8:12 pm |
|
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

|
Posted:
Sun Nov 09, 2003 8:14 pm |
|
You still have not entered your quotes w/i quotes
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

|
Posted:
Sun Nov 09, 2003 8:19 pm |
|
Great, now i get what you mean about the within quotes having the \
Thanks Gaylen |
|
|
|
 |
sqzdog

|
Posted:
Sun Nov 09, 2003 9:49 pm |
|
|
|
 |
|