Changes to Phile Core
This page tracks the various small tweaks I made to the phile core. See the referenced page for more information or to make comments.
System Config/DEFINE
See One Phile Multiple Sites. I wanted to use a shared system folder for multiple sites. Files changed:
- index.php
Proper link URLS
- don't use the base tag from the head section of the templates
- use base_url explicitely in templates. i.e.
<li><a href="{{ base_url }}/{{ page.url }}">{{ page.title }}</a></li>
Files changed:
- theme files *.html
This is somewhat related to the problem of subfolder links links in markdown on an index or excerpt pages.
The Request URI
Phile does not let you change the request_uri. Pico does let you change it. Ability to change it resolves some issues and gives plugins more flexibility. I needed several virtual pages. In any case I changeded these lines in Core.php
method initializeCurrentPage()
.
* @triggerEvent request_uri this event is triggered after the request uri is detected.
*
*/
//jacmgr:: need to be able to change uri in plugin
//Event::triggerEvent('request_uri', array('uri' => $uri));
Event::triggerEvent('request_uri', array('uri' => &$uri));
Files changed: * Core.php
The Page Model
I've made 3 changes in the Page model.
1) Added some getters
See the blog post.
Files Changed:
- Lib\Phile\Model\Page.php
I needed to get the full raw text content un-parsed. There were no getters in the page model for that. I added the following getters, getContentRaw()
and getRawData()
.
2) Added a setter for Meta
See the blog post.
I needed to be able to set meta data into a page. There were no setters in the page model for that.
These are the setters and getters I added.
/**
* Page Model JACMGR ADDITIONS
* by jacmgr
*/
//jacmgr: set some meta
public function setMeta($key, $value) {
$this->meta->set($key, $value);
}
//jacmgr: Get the Content section of file without parsing
public function getContentRaw() {
return $this->content;
}
//jacmgr: Get the full page content
public function getRawData() {
return $this->rawData;
}
//SETTERS
public function setRawData($content) {
$this->rawData = $content;
}
public function setUrl($newUrl) {
$this->url = $newUrl;
}
3) Need to adjust the before_parse trigger
Should be able to modify the content in the before_parse trigger. This change does that.
//Event::triggerEvent('before_parse_content', array('content' => $this->content, 'page' => &$this));
Event::triggerEvent('before_parse_content', array('content' => &$this->content, 'page' => &$this));
Twig and Phile Settings
I made 2 changes in the TWIG object.
Files Changed:
- Phile\plugins\phile\templateTwig\Classes\Template\Twig.php
1) Phile Settings
NO CHANGES MADE in PHILE 1.0. I don't seem to have this problem, but we'll see in the future, since Phile 1.0 still acts the same way.
For Phile 0.9 See the blog post. Noticed that some settings that were made in plugins were not making it into template.
The render
method is using a $this->settings
that was defined in the constructor. Many plugins could have added more settings since then?
2) Added a template exist check
NO CHANGES MADE in PHILE 1.0. I don't seem to have this problem, but we'll see in the future. Stile monitoring
For Phile 0.9: See the blog post. When use a meta template
phile does not check if the template actually exists. So it will throw an exception if it does not exist. I would rather it simply uses the default template if the meta template
is not found.
I think I can actually make this a plugin instead of modify core, but seems like core behavior to me.