PHPackages                             joseym/li3\_partials - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. joseym/li3\_partials

ActiveLithium-library

joseym/li3\_partials
====================

The partial plugin for Lithium(li3) provides flexibility to pass template sections from view to the layout.

0209PHP

Since Mar 2Pushed 11y ago1 watchersCompare

[ Source](https://github.com/agborkowski/li3_partials)[ Packagist](https://packagist.org/packages/joseym/li3_partials)[ RSS](/packages/joseym-li3-partials/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Partial Template support for [li3](http://lithify.me)
=====================================================

[](#partial-template-support-for-li3)

Plugin to pass template sections from view to the layout.

Installation
------------

[](#installation)

1. Clone/Download the plugin into your app's `libraries` directory.
2. Tell your app to load the plugin by adding the following to your app's `config/bootstrap/libraries.php`:

    ```
     Libraries::add('li3_partials');

    ```

Features
--------

[](#features)

1. Assign strings or entire blocks of markup to a partial.

Usage
-----

[](#usage)

**Blocks**

There have been a number of times I was working on a project and had a clean layout rendered but the client required that something in the layout change based on what view was rendered. I used elements and view `context` asignments for a while but that was neither elegant or enjoyable.

This is designed as a way to pass markup changes to section in a layout based on your view.

- #### In your view

    [](#in-your-view)

wrap the markup you want passed to the layout in `` tags with a `name` attribute.

```
``` html
Sidebar for this view!
```

```

- #### In your layout

    [](#in-your-layout)

There are 2 ways to print a blocked partial in your view

```
1. Call the blocks partial name and assign type `block`

	``` php

	```

2. Call a partial block and pass the partials name

	```	php

	```

```

Anywhere that you decide to place either of those will render the partial that was defined in your view at that location.

**Strings**

Similar to blocks, this method is used to pass strings of text to a layout.

*"Why?" asks you, "Good question!" I reply*

Think in terms of a page description or keywords, these may need to change based on a page view but I could find no easy way to get these requirements to the layout.

- #### In your view

    [](#in-your-view-1)

In the head of your view template (or anywhere, really, I just think it's cleaner to keep these together at the top) add:

```
``` php

```
It doesn't matter what you name this method, just keep in mind that that name will be how you call it in the layout.

```

- #### In your layout

    [](#in-your-layout-1)

Ok, so we defined keywords for our view! lets add them to the meta tag

```
``` html

```

*"That's foolish, it's easier just to use the other method!"* you exclaim. Hold tight, Fredword! I'll explain why you might want to do this below.

Sharing Names
-------------

[](#sharing-names)

There may be a case where you define both a partial string and partial block with the same name. To ensure that you pull the right one thee are 2 methods for each (actually 3 for .

**Strings**

```
