PHP in content

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
wientanz

PHP in content

Post by wientanz »

Ok, don't laugh at me. I need to add some PHP code in my content for a DB request. And I know that I have to use other tags than .

I tried searching, but I can't find it anywhere. Help?
westis

Re: PHP in content

Post by westis »

I'd say your best bet is to create a user-defined tag and then include that tag in your page.

Int he user-defined tag, leave out , as that is added automatically. The tag you insert on your page is then {nameoftag}. I think that should work.
cyberman

Re: PHP in content

Post by cyberman »

It's called user defined tag - please look here:).
wientanz

Re: PHP in content

Post by wientanz »

beat you to it by approx. 5 min. ;-)

Found it after googling the forum
wientanz

Re: PHP in content

Post by wientanz »

Since I've got a page mixed HTML and PHP between the lines I echo'ed the HTML so that I only have to use 1 tag. Copy&Pasted the edited code to userdefined plugins, inserted a {Pluginname}-tag into the content and voila... nothing happened  ???

Can't believe I'm having all these troubles getting my old site adapted...
cyberman

Re: PHP in content

Post by cyberman »

Can you post the code?
wientanz

Re: PHP in content

Post by wientanz »

Here it is. The working script is found here:

http://www.wientanz.com/mitarbeiter/gab ... baelle.php

Code: Select all

require "http://www.wientanz.com/mitarbeiter/gabriel/datenbank/include/functions.inc";


echo "<div align=center>";

  $res=mysql_query("select count(*) from ball;");
  $arr=mysql_fetch_array($res);

  $res2=mysql_query("select * from probe group by P_B_ID;");
  
  
  echo "<p><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Derzeit haben 
    wir <b>$arr[0]</b> in unserer Liste, davon <b>".mysql_affected_rows()."</b> 
    mit Eröffnungsinformationen.</font></p>"; 
  
  
  echo "<hr>";
  
  $res = mysql_query("select B_ID, B_Desc, B_Date, B_Ort, B_Price, B_Info, B_EMail, month(B_Date), year(B_Date) from ball ORDER BY B_Date;");
  
  $month=13;
  $first=1;
  
  
  
  echo "<table width=\"750\" border=\"0\">";
  while($arr=mysql_fetch_array($res)) {
     if($month!=$arr[7]) {	//Print new TableHeader
        $month=$arr[7];
        $duo=1; 
        
        
        

   
           echo "<tr><td> </td></tr> 	
    	   <tr bgcolor='#000066' bordercolor='#000066'> 
      		<td colspan='6'> 
        		<div align='center'><font size='3' color='#FFFFFF'><b><font face='Arial, Helvetica, sans-serif'><i>";
				 echo get_full_month($arr[7])." $arr[8]"; echo " </i></font></b></font></div>
      		</td>
    	   </tr>
    	   <tr bgcolor=#000066> 
	      <td bordercolor=#000066><b><font color=#FFFFFF>Datum</font></b></td>
	      <td bordercolor=#000066><b><font color=#FFFFFF>Ball</font></b></td>
	      <td bordercolor=#000066><b><font color=#FFFFFF>Ort</font></b></td>
	      <td bordercolor=#000066><b><font color=#FFFFFF>Kartenpreise</font></b></td>
	      <td bordercolor=#000066><b><font color=#FFFFFF>Telefonnummer</font></b></td>
	      <td bordercolor=#000066><b><font color=#FFFFFF>Probeninfo</font></b></td>
	   </tr>";
  
    
    
    
        }			//End of TableHead
     if($duo%2==0) $color="#99CCFF";
     else $color="#0099FF";
     $duo++;
     
     echo "<tr bgcolor=\"$color\">";    
     echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[2])."</font></td>";  
     echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[1])."</font></td>";     
     echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[3])."</font></td>";     
     echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[4])."</font></td>";  
     echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[5])."</font></td>";     
     echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">";

     $res2=mysql_query("select P_Link FROM probe where p_b_id='$arr[0]';");
     if(!$arr2=mysql_fetch_array($res2)) 
        echo "N/A"; 
     elseif(strlen($arr2[0])>1) echo "<a href=\"$arr2[0]\">Info</a>";
     else echo "<a href=\"http://www.wientanz.com/mitarbeiter/gabriel/datenbank/ballinfo.php?B_ID=$arr[0]\">Proben</a>";


     echo "</font></td>";        
     echo "<tr>";   
     }
  echo "</table>
     <br><hr><br>
     
   
  <p><font size='2'>Datenbank wurde zuletzt aktualisiert: "; echo get_last_change();  echo "</font> </p>
  <p> </p>
  <p> </p>
</div>";
cyberman

Re: PHP in content

Post by cyberman »

I'm not a real coder  :( ...

But if there's no solution you should try to include this part with Pi_Iframe from CMSMS Forge and you have nothing to change on the source  ::) .
wientanz

Re: PHP in content

Post by wientanz »

I'll try that. Thanks for the idea. Didn't know that something like that exists...
wientanz

Re: PHP in content

Post by wientanz »

Stupid me, I named the tag wrong. Forgot an "l".

Now the tag works, but what I don't understand is why the umlaute like äüö and other characters like ß,é,è and the likes are displayed wrong. You'll find it here.

http://www.bugovsky.com/index.php?page=Ballkalender

The script is the same as on my original site (see link above) where the characters are correct.

Any ideas?

Now I'm off slipping into my tuxedo. There is a ball in town tonight! (As on any friday and saturday night in January and February in Vienna...)
wientanz

Re: PHP in content

Post by wientanz »

An idea: In the DB the data only has the umlaut itself and not the HTML equivalent. i.e. an ä and not an ä

The original script accepts it, but not CMSMS. Any ideas? Don't want to edit over a 160 entries by hand...
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm
Location: North West England

Re: PHP in content

Post by Russ »

It is probably to do with character sets, you have no declaration in the web page HTML as far as I can see and it would also depend on the source of your data and perhaps your database settings if this is the source.

A normal html head declaration would be someting like (for UTF-8)



and you are also showing a language on your page of English, which doesn't seem right?
()


Hope this helps

Russ
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm
Location: North West England

Re: PHP in content

Post by Russ »

I should also add that with UTF-8 character sets and these types of characters you need to be sending the page the correct sort of entities. e.g. & = & etc.

Have a search for utf-8 character set entities in Google.

Russ
cyberman

Re: PHP in content

Post by cyberman »

wientanz wrote: Now the tag works, but what I don't understand is why the umlaute like äüö and other characters like ß,é,è and the likes are displayed wrong. You'll find it here.
You must set the encoding of your template to ISO-8859-1 to show the umlauts right.
wientanz

Re: PHP in content

Post by wientanz »

THX cyberman, you're my hero. Will try it this Sunday.
Post Reply

Return to “Developers Discussion”