MaMo Net



#1 24.09.2006, 21:39
schwim Abwesend
Mitglied
Dabei seit: 20.09.2006
Beiträge: 43


Betreff: Is there a way to have a "php include" in one of the side blocks?
Hi there guys,

I'm writing a script for a testimonial system, and I'd like to be able to show the visitors on the site the random testimonial block on the side of the system when they visit. Is there a way that I can use a simple include in one of the side blocks that I create?

If not, is there another way that I can do this? I saw that there is php in the header & footer files, but I'd really like the block to be on the side, if I can do it.

thanks,
json
↑  ↓

#2 27.09.2006, 13:54
MaMo Abwesend
Administrator
Dabei seit: 06.04.2004
Beiträge: 2.673


Betreff: Re: Is there a way to have a "php include" in one of the side blocks?
Hi.

Do you want the block in the navigation or somewhere else? You can easily create a plugin in the Admin Control Panel and include your PHP-Code there.

MaMo
Matthias M.
=> Support nur per Forum - dann haben alle etwas davon!
↑  ↓

#3 27.09.2006, 15:45
schwim Abwesend
Mitglied
Dabei seit: 20.09.2006
Beiträge: 43


Betreff: Re: Is there a way to have a "php include" in one of the side blocks?
Hi there MaMo, and thanks for the reply,

I just wanted the block to be on the left side of the page, either above or below the navigation links. I wasn't aware that I could insert php code through the administration system. Is this a possibility? I successfully created a block on the left, but I don't see how to add the php code Smiling

thanks very much,
json
Dieser Beitrag wurde 1 mal editiert, das letzte Mal am 27.09.2006, 15:46 von schwim. ↑  ↓

#4 27.09.2006, 16:12
schwim Abwesend
Mitglied
Dabei seit: 20.09.2006
Beiträge: 43


Betreff: Re: Is there a way to have a "php include" in one of the side blocks?
Hi there again MaMo,

I think I see how I'm supposed to do it, but I'm obviously not doing it correctly.

The first thing I did was create a plugin.

Name: Testimonial
Package: Verwandte Themen
Hook: Navigation
Code: include("/automonial/test_block.php");
File for this code: Testimonial.php
Priority: Before Verwandte Themen
Active: Yes

That provided these errors but then told me that it was successfully added, and that I needed to add it in the navigation manager:

Zitat:

Warning: fopen(modules/1/config.ini) [function.fopen]: failed to open stream: Permission denied in /home/roughing/public_html/classes/class.ini.php on line 207

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 233

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 228

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 233

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 228

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 233

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 228

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 233

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fwrite(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 242

Warning: fclose(): supplied argument is not a valid stream resource in /home/roughing/public_html/classes/class.ini.php on line 254

I went back and wrote the include with the full server path to the file, and reduced the error to this:

Zitat:

Undefined index: navigation in /home/roughing/public_html/admin/cms.php on line 405

but then it told me that the plugin had successfully been edited.

Then I went into the navigation manager, added Testimonial, set to run after menu and activated it.

When I go to the forum index, nothing has been added.

What have I done wrong?

thanks,
json
Dieser Beitrag wurde 1 mal editiert, das letzte Mal am 27.09.2006, 16:16 von schwim. ↑  ↓

#5 27.09.2006, 16:27
schwim Abwesend
Mitglied
Dabei seit: 20.09.2006
Beiträge: 43


Betreff: Re: Is there a way to have a "php include" in one of the side blocks?
After a little more testing I found the following.

It says that it should be located in /modules/23. I saw that modules wasn't set to 777, so I did that and re-edited the file, still nothing. So I created 23 for a directory, set it to 777, and tried it again. Still nothing got written to the directory, so it looks like the data is never getting written to the folder.

thanks,
json
↑  ↓

#6 27.09.2006, 16:39
MaMo Abwesend
Administrator
Dabei seit: 06.04.2004
Beiträge: 2.673


Betreff: Re: Is there a way to have a "php include" in one of the side blocks?
Hi,

first: You have added the plugin to the package "Related Topics". You have to create an own package.

I created a Package/Plugin for you with your code. You can download it and just import this package. You can delete your old Plugin.

I do not know why it does not write the file. Maybe a problem with safe mode?! Please be sure, that all files in modules have CHMOD 666 and all folders have CHMOD 777.

MaMo

Dateianhänge:
Dateityp-Informationen zu: zip  testimonial.zip
Downloads: 305
Dateigröße: 353 Byte


Matthias M.
=> Support nur per Forum - dann haben alle etwas davon!
↑  ↓

#7 27.09.2006, 16:50
schwim Abwesend
Mitglied
Dabei seit: 20.09.2006
Beiträge: 43


Betreff: Re: Is there a way to have a "php include" in one of the side blocks?
Hi there MaMo,

When I attempt to extract the zip file, it's empty Disappointed

I'm sorry for the troubles I'm causing.

thanks,
json
↑  ↓

#8 27.09.2006, 16:54
MaMo Abwesend
Administrator
Dabei seit: 06.04.2004
Beiträge: 2.673


Betreff: Re: Is there a way to have a "php include" in one of the side blocks?
Hi,

I think there are some problems because I have exported it with windows. Please try this package (don't ectract the package, just import it in your Admin Control Panel).

MaMo

Dateianhänge:
Dateityp-Informationen zu: zip  testimonial.zip
Downloads: 315
Dateigröße: 347 Byte


Matthias M.
=> Support nur per Forum - dann haben alle etwas davon!
↑  ↓

#9 27.09.2006, 16:59
schwim Abwesend
Mitglied
Dabei seit: 20.09.2006
Beiträge: 43


Betreff: Re: Is there a way to have a "php include" in one of the side blocks?
Hi there MaMo,

Relaxing the open_basedir restriction fixed my problems with adding a plugin, thanks very much!

My code seems to be breaking the forum however Smiling

thanks,
json
↑  ↓

#10 27.09.2006, 17:02
schwim Abwesend
Mitglied
Dabei seit: 20.09.2006
Beiträge: 43


Betreff: Re: Is there a way to have a "php include" in one of the side blocks?
Do you see anything I might need to change to get this to work in the forum system?

When running it, I currently get the following error after my block loads:

Zitat:

Fatal error: Database error: 1146: Table 'roughing_automonial.v_pm' doesn't exist - File: /home/roughing/public_html/templates/1/header.html(54) : eval()'d code on line 26 in /home/roughing/public_html/classes/database/mysql.inc.php on line 291

here's the code:

DownloadText-Quelltext:
  1. include("config.php");
  2.  
  3.         /*this query will get the needed information to create the block as you would like it*/
  4.          $result = mysql_query('SELECT * FROM config') or exit(mysql_error());
  5.         while ($row = mysql_fetch_assoc($result)) {
  6.  
  7.         $debug = $row['debug'];
  8.         $block_width = $row['block_width'];
  9.         $block_scroll = $row['block_scroll'];
  10.         $block_showtitle = $row['block_showtitle'];
  11.         $block_showdate = $row['block_showdate'];
  12.         $block_showauth = $row['block_showauth'];
  13.         $block_showauthweb = $row['block_showauthweb'];
  14.         $block_titlecount = $row['block_titlecount'];
  15.         $block_textcount = $row['block_textcount'];
  16.  
  17. if('debug'==1){
  18. error_reporting(E_ALL);
  19. }
  20.  
  21.     /* this query will get a random testimonial result */
  22.  
  23.         $query = "select * from testimonials WHERE active=1 ORDER BY rand() LIMIT 1";
  24.  
  25.     $result = mysql_query ($query);
  26.     while ($row = mysql_fetch_assoc ($result)) {
  27.         /* display testimonials in a simple table */
  28.  
  29.                 $id = $row['id'];
  30.                 $postdate = $row['postdate'];
  31.         $author = stripslashes ($row['author']);
  32.         $authorweb = stripslashes ($row['authorweb']);
  33.         $authorwebname = stripslashes ($row['authorwebname']);
  34.         $title2 = stripslashes ($row['title']);
  35.         $testtext1 = stripslashes ($row['testtext']);
  36.         $testtext2 = strip_tags ($testtext1);
  37.  
  38.  
  39.                 //global $block_textcount, $block_titlecount;
  40.  
  41.                 function nicetrim ($s, $length) {
  42.  
  43.                           $str_to_count = html_entity_decode($s);
  44.                           if (strlen($str_to_count) <= $length) {
  45.                            return $s;
  46.                           }
  47.  
  48.                           $s2 = substr($str_to_count, 0, $length);
  49.                           $s2 = substr($str_to_count, 0, $length - 3);
  50.                           $s2 .= "... [More]";
  51.                           return htmlentities($s2);
  52.                         }
  53.  
  54.                 $testtext = nicetrim($testtext2, $block_textcount);
  55.                 $title = nicetrim($title2, $block_titlecount);
  56.  
  57.                 /* display the data */
  58.                                 echo("<div align=center>
  59.                                 <table width=260 border=1 cellpadding=1 cellspacing=1>");
  60. if($block_showtitle == 1) {
  61.                         echo("<tr>
  62.                                                 <td bgcolor='#ffffff' width=400>
  63.                                                 <font size=3><b>$title</b></font>
  64.                                                 </td>
  65.                                         </tr>");
  66.                                         }
  67.                         echo("  <tr>
  68.                                                 <td bgcolor='#ffffff'>
  69.                                                 <font size=2>$testtext</font><p>
  70.                                                 </td>
  71.                                         </tr>");
  72. if($block_showauth == 1) {
  73.                                         echo("<tr>
  74.                                                 <td align='right'>
  75.                                                 <font size='1'>$author</font>
  76.                                                 </td>
  77.                                         </tr>");
  78.                                         }
  79. if($authorweb != "") {
  80.  
  81.         if($block_showauthweb == 1) {
  82.                                         echo("<tr>
  83.                                                 <td align='right'>
  84.                                                 <font size='1'><a href='$authorweb' target='_blank'>$authorwebname</a></font>
  85.                                                 </td>
  86.                                         </tr>");
  87.                                         }
  88.                                 }
  89.                                 echo("<tr>
  90.                                                 <td bgcolor='#ffffff'>
  91.                                                 <font size=2>");
  92.                                                 include("$siteurl/includes/menu/menu.php");
  93.                                 echo("</font><p>
  94.                                                 </td>
  95.                                         </tr>
  96.                                 </table>
  97.                                 </div><br>
  98.                                 <br>
  99.                 ");
  100.                 }
  101.         }

thanks,
json
↑  ↓

Seiten (1): 1


Alle Zeitangaben in GMT +01:00. Aktuelle Uhrzeit: 09:13.