Topic: Call certains chunks |
|||
|---|---|---|---|
Posted: 2011-08-11 |
|||
|
User |
I want to have 4 chunks of content my client can change on the home page. Would be great to have the ability to call certains chunks of content rather than it all getting pulled in one go. {pyro:theme:partial name="content" chunk="chunkname"} This possible right now? |
||
| Quote | |||
Posted: 2011-08-11 |
# 1 | ||
|
User |
Installed Pyro chunks for now but would be nice to let the client do it all from the Page editor | ||
| Quote | |||
Posted: 2011-08-11 |
# 2 | ||
|
User |
Haven't used pyrochunks but just downloaded the latest, and it doesn't have a plugin. What you're doing in the tag up there is just loading a partial, and that act probably shouldn't be mixed with module stuff. What you need is to add a plugin.php file to the pyrochunks module's root so you can do something like this: {pyro:chunks:item chunk="chunkname"} ... some html tags ... {content} ... some html tags {/pyro:chunks:item} in the plugin.php file, you'd create a function called item(). This function would use the value given to the attribute 'chunk' to retrieve the record from the db and return it; the tags handle the rest. read the docs page for a little better treatment of the subject. |
||
| Quote | |||
Posted: 2011-08-11 |
# 3 | ||
|
User |
Just to clarify, i'm not entirely sure you NEED a plugin to do what you're asking. The developers clearly didn't see a need for one, and I normally wouldn't go against their judgment. However, if you're specifically looking to use tags then a plugin is what you want. |
||
| Quote | |||
Posted: 2011-08-12 |
# 4 | ||
|
Admin |
Lets avoid any confusion here shall we? Page Chunks - editable groups of a page. PyroChunks - A third-party add-on which essentially multi-line variables. Page Chunks are all displayed at the same time because they are all part of the same page. Why would you not show part of a page? They are wrapped in easily target-able divs so if you want to move things around then go for it. This is what they were designed for, but you don't need any Tags for that, just use CSS. |
||
| Quote | |||
Posted: 2011-08-12 |
# 5 | ||
|
User |
Thanks Phil. That was confusing, I apologize; didn't know about page chunks. I saw a tag in one of the views of pyrochunks that looked like this: {pyro:chunk:<?php echo $chunk->slug; ?>} Is that tag using page chunks? I couldn't understand how it could be a part of pyrochunks. |
||
| Quote | |||
Posted: 2011-08-12 |
# 6 | ||
|
Admin |
That is nothing to do with Page Chunks or any code the development team have ever written. PyroChunks looks scary, and I might have to delete it to stop confusion. Yuck. |
||
| Quote | |||
Posted: 2011-08-12 |
# 7 | ||
|
User |
Maybe just a name change? I'm sure it doesn't blow chunks. |
||
| Quote | |||
Posted: 2011-08-19 |
# 8 | ||
|
User |
Page Chunks are really great, but when I started develop more complex theme, chunks in that form (displayed at once) became too weak. So I wrote simple and ugly hack that displays exactly this chunk you want.<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Page Chunks Plugin
*
* Read specified page chunk
*
* @package PyroCMS
* @author michalsn
* @copyright Copyright (c) 2008 - 2011, PyroCMS
*
*/
class Plugin_Page extends Plugin
{
/**
* Data
*
* Loads a page chunk
*
* Usage:
* {pyro:page:chunk id="0"}
*
* @param array
* @return string
*/
function chunk()
{
$id = $this->attribute('id');
$data =& $this->load->_ci_cached_vars;
$dom = new DOMDocument();
$dom->loadHTML($data['template']['body']);
$xpath = new DOMXpath($dom);
$elements = $xpath->query('//*[@class and contains(concat(" ",normalize-space(@class)," ")," page-chunk ")]');
if (!is_null($elements))
{
foreach ($elements as $element)
{
$chunks[] = str_replace(' ', ' ', $dom->saveXML($element));
}
}
return isset($chunks[$id]) ? $chunks[$id] : '';
}
} |
||
| Quote | |||
Posted: 2011-08-19 |
# 9 | ||
|
Admin |
You are missing the purpose of chunks entirely. They are just a way to let users break up the content so A) they can use HTML or WYSIWYG (eventually Markdown / Textile, etc) and B) Position / Float the boxes using CSS. Other than that it's just the same as having a "body" in a page. |
||
| Quote | |||
