website/public/docs/v3.1.3/API/PHP/VV/shell.php

74 lines
No EOL
2.7 KiB
PHP

<?= VV::include("modules/snippet/Snippet.php") ?>
<?php // General information ?>
<section class="md">
<container>
<p>(Vegvisir 3)</p>
<h1><code>VV::shell()</code></h1>
<p>Wrap contents of a page within another page.</p>
<p>This method is similar to <a href=""><code>VV::include()</code></a> except it lets you place persistent content around the included page.</p>
</container>
</section>
<section class="md">
<container>
<h1>Description</h1>
<?= Snippet::put("docs/API/PHP/VV/shell/description", Snippet::PHP) ?>
<p><code>VV::shell()</code> is a powerful method which lets you put the contents of one page into a <code class="tag">vv-shell</code> tag on another page.</p>
<p>Subsequent navigations to pages using the same shell will preserve the outer shell's state. The shell will not be fetched again.</p>
</container>
</section>
<?php // Method parameters ?>
<section class="md">
<container>
<h2>Parameters</h2>
</container>
</section>
<section class="md inset">
<container>
<h3><code>pathname</code></h3>
<p>Path to a PHP shell page relative from <a href="">project root</a> which the contents of the initiator page will be wrapped inside.</p>
<details>
<summary>Example</summary>
<?= Snippet::put("docs/API/PHP/VV/shell/0", Snippet::PHP) ?>
</details>
</container>
</section>
<?php // Method return values ?>
<section class="md">
<container>
<h2>Return values</h2>
</container>
</section>
<section class="md inset">
<container>
<p>This method is buffered and will flush the buffer contents to <code>stdout</code> when the last shell has been imported.</p>
</container>
</section>
<?php // Examples ?>
<section class="md">
<container>
<h1>Examples</h1>
</container>
</section>
<section class="md inset">
<container>
<h2>Basic usage</h2>
<p>If we want the contents of page <code>/public/some-page.php</code> wrapped inside the contents of <code>/shells/some-shell.php</code>, we can do the following:</p>
<?= Snippet::put("docs/API/PHP/VV/shell/example-0-0", Snippet::PHP) ?>
<p>Place a <code>VV::shell()</code> snippet <strong>at the end</strong> of the page you wish to wrap.</p>
</container>
</section>
<section class="md inset">
<container>
<p>Now let's add a <code class="tag">vv-shell</code> tag somewhere in our <code>/shells/some-shell.php</code> file.</p>
<?= Snippet::put("docs/API/PHP/VV/shell/example-0-1", Snippet::PHP) ?>
<p>The contents of <code>/public/some-page.php</code> will <strong>replace</strong> the <strong>inner</strong> contents of the <code>vv-shell</code> tag.</p>
<p>The shell file acts like any other Vegvisir page, which means you have access to all <a href=""><code>VV</code></a> methods.</p>
</container>
</section>
<?php // Contribute ?>
<?= VV::shell("shells/docs") ?>