Und schon wieder eine Frage: Kann man 2 Blöcke in einen includen?

Begonnen von Kevke, 31 Januar 2004, 20:25:40

⏪ vorheriges - nächstes ⏩

0 Mitglieder und 2 Gäste betrachten dieses Thema.

Kevke

Würde gerne einen Center Block erstellen welcher zwei Blöcke
included hat.

Unzwar Random Pic und den Content Block.

Geht sowas?

Andi

Moin Kevke :)

das geht:

Alle Blöcke erzeugen ja, wenn man sie includet eine Variable $content.

 php
include("blocks/block-irgendwas_1.php");
$out1 = $content;
unset($content);

include("blocks/block-irgendwas_2.php");
$out2 = $content;

$content = $out1.$out2;
$blockfiletitele = "Der Titel für den Block";
 
schön´s Grüssle, Andi

NeMeSiSX2LC

So ich greif das Theme wieder mal auf und zwar hab ich auch sowas vor bloss das sich bei mir die blöcke die angezeigt werdenm sollen im Admin bereich einstellen lassen.

Nun hab alles schön erstellt bloss bleibt der center Block leer und die die blöcke die darin angezeigt werden sollen werden links angezeigt:-(

Hier mal der code:

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

global $bgcolor1, $bgcolor2, $prefix;
$cbinfo = sql_fetch_array(sql_query("select * from ".$prefix."_nsncb_config where cgid='1'"));
if ($cbinfo['enabled'] == '1') {
    if ($cbinfo['height'] <> "") { $cheight = "height='".$cbinfo['height']."' "; } else { $cheight = ""; }
    $content = "<table width='100%' ".$cheight."border='0' cellspacing='1' cellpadding='0' bgcolor='$bgcolor2'><tr><td valign='top'>\n";
    $content .= "<table width='100%' ".$cheight."border='0' cellspacing='1' cellpadding='4' bgcolor='$bgcolor1'><tr>";
    $result3 = sql_query("SELECT * FROM ".$prefix."_nsncb_blocks WHERE cgid='1' ORDER BY cbid");
    while($cbidinfo = sql_fetch_array($result3)) {
        if ($cbidinfo['cbid'] <= $cbinfo['count']) {
            if ($cbidinfo['wtype'] == '0') {
                $content .= "<td width='".$cbidinfo['width']."' valign='top' align='center'>\n";
            } else {
                $content .= "<td width='".$cbidinfo['width']."%' valign='top' align='center'>\n";
            }
            cb_blocks($cbidinfo['rid']);
            $content .= "</td>\n";
        }
    }
    $content .= "</tr></table>\n";
    $content .= "</td></tr></table>\n";
    $content .= "<br>";
}
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

jogi24


NeMeSiSX2LC

Jupps das ist er. Wobei ist eigentlich kein block da er ja included wird im header und footer. Daher wollte ich denn als richtig block haben das man den kram besser positionieren kann.
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

Andi

Moin :)

wenn die Blockinhalte links ausgegeben wérden, dann wird das bestimmt durch einen Echo-Befehl ausgelöst.
Was macht denn die Funktion cb_blocks() ?
Der Rest von dem Code sieht eigentlich normal aus...
schön´s Grüssle, Andi

NeMeSiSX2LC

In der funktion ist nix von echos zu sehen ist nur ne abfrag ob block da oder nicht.
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

Andi

Jop, aber irgendwo / irgendwas muss den Inhalt der Variablen $content ja ausgeben...
schön´s Grüssle, Andi

NeMeSiSX2LC

global $prefix, $bgcolor1, $bgcolor2;
$cbinfo = sql_fetch_array(sql_query("select * from ".$prefix."_nsncb_config where cgid='1'"));
if ($cbinfo['enabled'] == '1') {
    if ($cbinfo['height'] <> "") { $cheight = "height='".$cbinfo['height']."' ";
} else
{
$cheight = "";
}
    $content = "<table width='100%' ".$cheight."border='0' cellspacing='1' cellpadding='0' align='center'><tr><td valign='top' align='center'>\n";
    $content .= "<table width='100%' ".$cheight."border='0' cellspacing='1' cellpadding='4' align='center'><tr>";
    $result3 = sql_query("SELECT * FROM ".$prefix."_nsncb_blocks WHERE cgid='1' ORDER BY cbid");
    while($cbidinfo = sql_fetch_array($result3)) {
        if ($cbidinfo['cbid'] <= $cbinfo['count']) {
            if ($cbidinfo['wtype'] == '0') {
                $content .= "<td width='".$cbidinfo['width']."' valign='top' align='center'>\n";
            } else {
                $content .= "<td width='".$cbidinfo['width']."%' valign='top' align='center'>\n";
            }
            $content .= cb_blocks($cbidinfo['rid']);
            $content .= "</td>\n";
        }
    }
    $content .= "</tr></table>\n";
    $content .= "</td></tr></table>\n";
    $content .= "<br>";
}


so sieht im mom mein block hinhalt aus
und so m die function cb_blocks:

function cb_blocks($rid) {
    global $prefix, $db, $admin, $user;
    $sql = "SELECT * FROM ".$prefix."_nsncb_blocks WHERE rid='$rid'";
    $result = sql_query($sql);
    while($row = sql_fetch_array($result)) {
        $title = $row['title'];
        $filename = $row['filename'];
        $content = $row['content'];
        if ($filename == "" AND $content > "") {
            themecenterbox($title, $content);
        } elseif ($filename > "" AND $content == "") {
            $file = @file("blocks/$filename");
            if (!$file) {
                $content = _BLOCKPROBLEM;
            } else {
                include("blocks/$filename");
            }
            if ($content == "") { $content = _BLOCKPROBLEM2; }
            themecenterbox($title, $content);
        } elseif ($filename == "" AND $content == "") {
            $content = _BLOCKPROBLEM2;
            themecenterbox($title, $content);
        }
    }
}


Mal sehen ob du da was sieht weil der hinghalt wird immer noch rechts angezeigt.
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

NeMeSiSX2LC

Ja ich weiss ihr habt viel um die Ohren aber das wäre mir doch jetzt mal wichtig.
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

Andi

Moin :)

du kriegst jetzt nicht die lösung, sondern nur nen kleinen Stuppser.

themecenterbox($title, $content);

Schau mal, was die Funktion themecenterbox() macht ;)

Zitatwenn die Blockinhalte links ausgegeben wérden, dann wird das bestimmt durch einen Echo-Befehl ausgelöst.
Was macht denn die Funktion cb_blocks() ?
schön´s Grüssle, Andi

NeMeSiSX2LC

#11
Jo aber die themecenterbox benutzt doch nur echo´s wenn die function thememiddlebox nicht vorhanden ist. Also müsste ich die thememiddlebox auf $content abändern?

Nachtrag: Sauerei heute hängt es wieder total also die echos in beiden funktionen müssen bleiben sonst geht ja garnix mehr. Geb mal noch einen Tip bitte:-)

Ach noch was der Inhalt wird links untereinander angezeigt also schon ganz anderst wie es im block selbst eigentlich erstellt ist. wenn ich es mit echo mache wird er auch links angezeigt aber die darstellung stimmt wenigtens;-)
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

NeMeSiSX2LC

Zitat von: NeMeSiSX2LC am 04 November 2004, 08:18:52
Ja ich weiss ihr habt viel um die Ohren aber das wäre mir doch jetzt mal wichtig.

Mach auch nicht wieder aber würde mich jetzt doch mal interessieren.
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

Andi

ZitatJo aber die themecenterbox benutzt doch nur echo´s wenn die function thememiddlebox nicht vorhanden ist. Also müsste ich die thememiddlebox auf $content abändern?

Nachtrag: Sauerei heute hängt es wieder total also die echos in beiden funktionen müssen bleiben sonst geht ja garnix mehr. Geb mal noch einen Tip bitte:-)

Ach noch was der Inhalt wird links untereinander angezeigt also schon ganz anderst wie es im block selbst eigentlich erstellt ist. wenn ich es mit echo mache wird er auch links angezeigt aber die darstellung stimmt wenigtens;-)

Sorry, aber da versteh ich jetzt garnix.....

Tatsache ist, dass themecenterbox und thememiddlebox die Ausgaben per echo ausgeben. Dadurch landet die Ausgabe nicht in der Variablen $content sondern werden bereits beim generieren des Blocks, ausserhalb der theme-Haupttabelle ausgegeben.

Eine Möglichkeit das zu umgehen, wäre die Ausgabe in den Ausgabepuffer zwischenzuspeichern und das dann in die Variable zu lenken....
Stichwort ob_start()
schön´s Grüssle, Andi

NeMeSiSX2LC

ZitatSorry, aber da versteh ich jetzt garnix.....

Tatsache ist, dass themecenterbox und thememiddlebox die Ausgaben per echo ausgeben. Dadurch landet die Ausgabe nicht in der Variablen $content sondern werden bereits beim generieren des Blocks, ausserhalb der theme-Haupttabelle ausgegeben.

Eine Möglichkeit das zu umgehen, wäre die Ausgabe in den Ausgabepuffer zwischenzuspeichern und das dann in die Variable zu lenken....
Stichwort ob_start()

Das verstehe ich nun wieder nicht wo soll die ausgabe gepuffert werden? Im Block

Ach ist es nicht schön wenn die Kommunikation Funktioniert?
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

jubilee

Hallo !
ZitatDas verstehe ich nun wieder nicht wo soll die ausgabe gepuffert werden? Im Block
Guckst Du in der PHP-Dokumentation nach
ob_start --->
ZitatThis function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.

The contents of this internal buffer may be copied into a string variable using ob_get_contents(). To output what is stored in the internal buffer, use ob_end_flush(). Alternatively, ob_end_clean() will silently discard the buffer contents.

An optional output_callback function may be specified. This function takes a string as a parameter and should return a string. The function will be called when ob_end_flush() is called, or when the output buffer is flushed to the browser at the end of the request. When output_callback is called, it will receive the contents of the output buffer as its parameter and is expected to return a new output buffer as a result, which will be sent to the browser.

Note:
In PHP 4.0.4, ob_gzhandler() was introduced to facilitate sending gz-encoded data to web browsers that support compressed web pages. ob_gzhandler() determines what type of content encoding the browser will accept and will return it's output accordingly.

Output buffers are stackable, that is, you may call ob_start() while another ob_start() is active. Just make sure that you call ob_end_flush() the appropriate number of times. If multiple output callback functions are active, output is being filtered sequentially through each of them in nesting order.

ob_end_clean(), ob_end_flush(), ob_clean(), ob_flush() and ob_start() may not be called from a callback function. If you call them from callback function, the behavior is undefined. If you would like to delete the contents of a buffer, return "" (a null string) from callback function.

MfG
jubilee

NeMeSiSX2LC

Joa schon klar aber wo einsetzen das leuchtet mir grad nicht ein
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

Andi

Hier die ungetestete, aber von unnötigem Kram befreite, Version der Funktion:
<?php

function cb_blocks($rid) {
  global $prefix;
  $sql "SELECT * FROM ".$prefix."_nsncb_blocks WHERE rid='".intval($rid)."'";
  $result sql_query($sql);
  $row sql_fetch_array($result);
  if (empty($row['filename']) && !empty($row['content'])) {
    $content $row['content'];
  } elseif (!empty($row['filename']) && empty($row['content'])) {
    if (is_file("blocks/".$row['filename'])) {
      include("blocks/".$row['filename']);
    } else {
      $content _BLOCKPROBLEM;
    }
  if (empty($content)) { 
    $content _BLOCKPROBLEM2
  }
  ob_start();
  themecenterbox($row['title'], $content);
  return ob_get_clean();
}

?>


Wobei ich mir nicht ganz sicher bin, ob das nicht noch einfacher geht. Die DB-Abfrage in der Funktion müsste eigentlich unnötig sein, weil beim Aufruf die Tabelle ja schonmal abgefragt wurde....
Aber that's nuke live...
schön´s Grüssle, Andi

NeMeSiSX2LC

so also die blöcke sind schonmal da wo sie sein soll aber darunter steht jetzt das

Fatal error: Cannot use object of type stdClass as array in \includes\mx_baseconfig.php on line 154

  ob_start();
  themecenterbox($row['title'], $content);<<<<< 154
  return ob_get_clean();
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

NeMeSiSX2LC

Aja wenn man es so macht

$title = $row['title'];
ob_start();
  themecenterbox($title $content);
  return ob_get_clean();

Dann gehts
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

Andi

schön´s Grüssle, Andi

NeMeSiSX2LC

CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

Andi

schön´s Grüssle, Andi

NeMeSiSX2LC

Was denn eine file für functionen sowie my_header gibt es ja nicht
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1

_Gerry_

Zitat von: NeMeSiSX2LC am 05 November 2004, 13:01:00
Was denn eine file für functionen sowie my_header gibt es ja nicht
Naja man kann ja auch selbst eine Datei schreiben und includen! ;)
CMS-Version: pragmaMx 0.1.11, 1.33.2.12.2.9/2009-05-10   
PHP-Version: 5.2.0-8+etch5~pu1
MySQL-Version: 5.0.32-Debian_7etch1
Server-Version: Apache/2.2.3 (Debian) mod_ssl/2.2.3 OpenSSL/0.9.8c

NeMeSiSX2LC

So gehts doch auch für was heisst das teil schliesslich baseconfig?
CMS-Version: pragmaMx 0.1.8, 1.20.4.5/2006-03-10     
PHP-Version: 5.1.2
MySQL-Version: 5.0.15-max-log
Server-Version: Apache/2.0.55
phpMyAdmin-Version: 2.7.0-pl1