Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'view controller parameter'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hello together, maybe I don't see the forest for the trees, but I'm struggling with parameter handling of controllers and views... To start with Yii, MVC and RBAC I tried do build a simple page (something like http://mysite.domain.com/authitem) that draws the parent->childhood relations of my AuthItems using the prebuild Yii demo app. I manualy installed the PEAR extension "Image_Graphviz" (pear install ...) to draw the graphs. I created the model with Giix and edited the AuthItemController.php manualy (I copied the stuff from other controllers Accessing the tables, building the graph and "draw" it in the browser went fine with only one bad thing: I did it all in the controller (just to be sure Graphviz works). And it does, it works great! After that I tried to do it the MVC style and modified .../views/authItem/index.php. Instead of doing it directly with $graph->image(), I switched to $this->render() in AuthItemController::actionIndex() (please have a look on the code snippets below). But this led me into a XML error message shown in the browser: ------------------------XML Error------------------------ XML-Verarbeitungsfehler: XML- oder Text-Deklaration nicht am Beginn der Entität Adresse: http://localhost/stable/authItem Zeile Nr. 49, Spalte 1:<?xml version="1.0" encoding="UTF-8" standalone="no"?> ^ ------------------------XML Error------------------------ This means translated something like: XML or text declaration not at start of entitiy (row 49, col 1) What did I wrong? Does the view not have access to the $graph instance forwarded from the controller? I thought this will be done with $this->render('index', array( 'graph' => $graph));? Regards, Boris My code: ------------------------[controllers/AuthItemController.php]------------------------ <?php require_once 'Image/GraphViz.php'; class AuthItemController extends GxController { public function filters() { //Nothing special } public function accessRules() { //Nothing special } // Here it goes... public function actionIndex() { $graph = new Image_GraphViz(); // Get the data from table AuthItem $cmd = Yii::app()->db->createCommand(); $cmd->select = 'name, type, bizrule'; $cmd->from = 'AuthItem'; $result = $cmd->query(); // Build the graph nodes foreach ($result as $row) { switch ($row['type']) { case 0: $shape = 'box'; break; case 1: $shape = 'box'; break; case 2: $shape = 'house'; break; default: $shape = 'box'; } $graph->addNode( $row['name'], array( 'label' => $row['name'], 'shape' => $shape, ) ); } // Get the data from table AuthItemChild $cmd = Yii::app()->db->createCommand(); $cmd->select = 'parent, child'; $cmd->from = 'AuthItemChild'; $result = $cmd->query(); // Build the graph egdes foreach ($result as $row) { $graph->addEdge( array( $row['parent'] => $row['child'] ) ); } // "Drawing" the graph in the browser without MVC. Works fine. // $graph->image(); $this->render('index', array( 'graph' => $graph)); } } ?> ------------------------[controllers/AuthItemController.php]------------------------ ------------------------[views/authItem/index.php]------------------------ <?php /* @var $graph GrahpViz Instance */ [...] ?> <h1><?php echo GxHtml::encode(AuthItem::label(2)); ?></h1> <?php $graph->image(); ?> [...] ------------------------[views/authItem/index.php]------------------------
×
×
  • Create New...