TinyPortal

Development => Support => Topic started by: JCphotog on July 27, 2007, 01:59:06 AM

Title: Php in html article?
Post by: JCphotog on July 27, 2007, 01:59:06 AM
Hi.  I've got a great article running in a php block using cpmfetch and some text.  It looks really cool.  I have the images in a vertical table and some text talking about the images to the left.  I want to turn this block into an interview with featured members, so I'd love it if I could show an introduction, then allow users to click read more just like a regular article.  Is there any way to do an intro with php blocks? or is there some way to do this in a regular block?  I tried using tags like: <?php   my code here  ?> in a non php article but I was not successful.   I'm still a newbie, but I really appreciate the help!!
Title: Re: Php in html article?
Post by: IchBin on July 27, 2007, 02:28:17 AM
You cannot use the <?php tags. Just change your article to a php article and echo (http://www.ichbin.us/index.php?topic=19.0) all your stuff.
Title: Re: Php in html article?
Post by: feline on July 27, 2007, 12:09:33 PM
You must NOT echo all stuff.
try uses this as example ...

<?php
any php code
?>

html code
<?php
php code
?>

html code


and so one ...

Fel
Title: Re: Php in html article?
Post by: G6Cad on July 27, 2007, 12:30:39 PM
But the php tags will not apply correct when you add them in a block or article as they are predifined with the code when you create them  ???
Title: Re: Php in html article?
Post by: feline on July 27, 2007, 12:48:39 PM
ahh ... I not have tested that at the moment.
Normaly, it's works ...

Fel
Title: Re: Php in html article?
Post by: Crip on July 27, 2007, 01:13:54 PM
Like in a ssi_php example: <?php ssi_recentTopics(); ?> will not work but like this it will work: ssi_recentTopics(); !
Title: Re: Php in html article?
Post by: JCphotog on July 30, 2007, 02:00:54 AM
Thanks for the replies.  Sorry.  I forgot to set notification.
So you can put php into a normal article?

I got errors when I tried with <?php in a regular article. 
When I tried "add php" with out <?php everything worked, but I couldn't get an intro.

Here's a sample of what I'm using (remember I'm still a newbie, I'll start using css tags instead of html soon...)

$featureprofile = '<font color="#3300cc" size="4">Featured profile</font><br><font size="3"><a href="/forum/index.php?action=profile;u=1022">Name Here</a></font><br />';
$featured3 = "<br><font size='2'>Intro. Click this <a href='/forum/index.php?topic=4860.0'>link</a> for more info</font><br><br />
<b>Tell us about your art.</b><br>Text here<br>k<br />";
$featureprofile2 = "<br><font size='2'>Another link <a href='/forum/index.php?action=profile;u=1022'>name or images</a> for more information.</font><br />";

echo $featureprofile;
echo '<table><tr>';
echo '<td width="70%" valign="top">';
echo $featured3, $featureprofile2;
echo '</td>';
echo '<td><center>';  include_once "/public_html/gallery/cpmfetch/cpmfetch.php"; 
  $objCpm = new cpm("/public_html/gallery/cpmfetch/cpmfetch_config.php");
  $options = array( "cellattributes" => array("align" => "center","height" => "105", "width"=>"110"), "cellStyle" => "align='center'"  );
  $objCpm->cpm_viewRandomMediaFrom("cat=1,2,3:owner=felixkat", 5, 1, $options);
  $objCpm->cpm_close();
echo '</center></td>';
echo '</tr></table>';

Title: Re: Php in html article?
Post by: JCphotog on July 31, 2007, 09:16:00 PM
I imagine I could just create 2 php articles.  One short version with a link to another article with more text and images to get the "into" feel.  Can you define variables in one php article, and echo the same variable in another article?
Title: Re: Php in html article?
Post by: feline on July 31, 2007, 10:30:45 PM
shure ..
you have to use in article 1 (example)

global $context;
$context['myvar'] = 'asyouwant';


in the other article you can use

global $context;
echo $context['myvar'];


Note, that you must load both articles in the same content.

Fel
Title: Re: Php in html article?
Post by: JCphotog on August 01, 2007, 05:01:46 AM
Hi thanks!  I'll give that a try!!
I'm sorry if this is a silly question, but what does it mean to load both articles in the same content? 
Title: Re: Php in html article?
Post by: IchBin on August 01, 2007, 05:03:13 AM
Both articles must be loaded on the same page to do this.
Title: Re: Php in html article?
Post by: JCphotog on August 01, 2007, 05:10:44 AM
Thanks IchBin. 

I was thinking of having one as an intro on the front page, and the other not on the front page.    So this probably won't work.  Hell.  Maybe I'm just lazy.  I can always define the variables for each article  Any other thoughts about creating a php intro?
Title: Re: Php in html article?
Post by: IchBin on August 01, 2007, 06:23:27 AM
You can always add that code to an invisible block as well. :D
Title: Re: Php in html article?
Post by: marzi on August 01, 2007, 01:12:35 PM
I have the following code working fine in a standard PHP page that uses the <?php  ?>  tags:

<BR>
<FONT COLOR="#80000">__ Enter Your Name (optional):</font><BR>
<INPUT TYPE=text NAME="name" SIZE=40 MAXLENGTH=60 VALUE="<? echo $name; ?>">
<P>


and have tried to get it to work in a Tiny Portal PHP article by changing it to the following but I cannot figure out how to handle VALUE="<? echo $name; ?>" correctly. What am I doing wrong here?

echo '
<BR>
<FONT COLOR=\"#80000\">__ Enter Your Name (optional):</font><BR>
<INPUT TYPE=text NAME=name SIZE=40 MAXLENGTH=60 VALUE= echo $name;>
<P>';
Title: Re: Php in html article?
Post by: feline on August 01, 2007, 04:46:12 PM
Quote from: marzi on August 01, 2007, 01:12:35 PM
and have tried to get it to work in a Tiny Portal PHP article by changing it to the following but I cannot figure out how to handle VALUE="<? echo $name; ?>" correctly. What am I doing wrong here?

echo '
<BR>
<FONT COLOR=\"#80000\">__ Enter Your Name (optional):</font><BR>
<INPUT TYPE=text NAME=name SIZE=40 MAXLENGTH=60 VALUE= echo $name;>
<P>';


you have to use follow:

echo '
<BR>
<FONT COLOR="#80000">__ Enter Your Name (optional):</font><BR>
<INPUT TYPE="text" NAME="name" SIZE="40" MAXLENGTH="60" VALUE="'. $name .'">
<P>';


Fel
Title: Re: Php in html article?
Post by: marzi on August 01, 2007, 08:14:25 PM
Danke  :)

marzi
Title: Re: Php in html article?
Post by: Hobox on August 02, 2007, 12:05:10 AM
I use HTML in a php-article. I just started the article with ?> and entered some html and then just added <?php at the end again.

The reason I did this was to be able to use some php variables in the middle of the html block.

Worked fine for me. Maybe not the best and perfect way, but at least it did what I wanted without to much fuss.