We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

$DSP->view (any examples)

Development and Programming

Patrick Mc's avatar
Patrick Mc
19 posts
16 years ago
Patrick Mc's avatar Patrick Mc

Hello,

I’m working in a custom module mcp file, and I’d like to start creating some views. I checked out the example ‘fortunes’ module but I’m still not having any luck. None of my other modules contain view files (currently working in 1.6.8) that I can use as an example.

I have a module called vehicles with the following directory tree:

vehicles -index.html -mcp.vehicles.php -mod.vehicles.php views -vehicles_home.php

I’m trying to call in the view file with this in the mcp.vehicles.php file (with no luck)

$DSP->body .= $DSP->view('views/vehicles_home.php', $vars, TRUE);

The view file contains:

<div id='contentNB'>

    <h1>TEST TEST TEST</h1>

    <div class='itemWrapper'>

        <h5><a href="http://index.php?S=0&C=modules&M=vehicles&P=add">Add Vehicle</a></h5>

    </div>
    
    <div class='itemWrapper'>
    
        <h5><a href="http://index.php?S=0&C=modules&M=vehicles&P=view">View Vehicles</a></h5>
        
    </div>
    
</div>

Any ideas or simple examples I could check out? Thanks.

       
Manuel Payano's avatar
Manuel Payano
144 posts
16 years ago
Manuel Payano's avatar Manuel Payano

I think you can leave out the .php extension. And you can call your views without the /views/ folder in the name like:

$DSP->body .= $DSP->view('vehicles_home', $vars, TRUE);

And if you need a module as example that uses view files try our modules at www.devdemon.com. They all use view files.

       
Patrick Mc's avatar
Patrick Mc
19 posts
16 years ago
Patrick Mc's avatar Patrick Mc

Worked like a charm! Thank you thank you. 😊

       
Patrick Mc's avatar
Patrick Mc
19 posts
16 years ago
Patrick Mc's avatar Patrick Mc

Well, I’m not having any luck passing variables into my view? Any simple examples?

       
Manuel Payano's avatar
Manuel Payano
144 posts
16 years ago
Manuel Payano's avatar Manuel Payano
$vars = array('number_one' => 'foo', 'some_other' => 'lorem_ipsum');

$DSP->body .= $DSP->view('vehicles_home', $vars, TRUE);

In the view file:

<strong><?=$some_other?></strong>

<?=$number_one?>

Hope it helps

       
Patrick Mc's avatar
Patrick Mc
19 posts
16 years ago
Patrick Mc's avatar Patrick Mc

Very cool! Thank you for the help. 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.