Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using $this when not in object context in #44

Closed
Frodox opened this issue Feb 2, 2014 · 11 comments
Closed

Using $this when not in object context in #44

Frodox opened this issue Feb 2, 2014 · 11 comments

Comments

@Frodox
Copy link
Contributor

Frodox commented Feb 2, 2014

I try to use phileTwigFilters , limit_words filter, but it returns an error:

Fatal error: Using $this when not in object context in   

/.../phile/plugins/phileTwigFilters/plugin.php on line 25

line 25: return trim(substr($string, 0, $pos[$this->settings['limit']])) . '...';


Actually, it there any way to modify meta-data of page depend on parsed content?
I didn't find any appropriate event, and the twig filter does not want to work too :D

I want to port my Pico Custom Post Preview Plugin...

@Frodox
Copy link
Contributor Author

Frodox commented Feb 2, 2014

Also, there is an event: template_engine_registered, but there are no lines in the docs about this :(

@james2doyle
Copy link
Member

Hey there. I just checked the plugin. I didn't get the same error.

You are right about the template_engine_registered event. I can add the event to the docs.

@Frodox
Copy link
Contributor Author

Frodox commented Feb 2, 2014

Did you use limit_words filter, and set {{ page.content|limit_words }} exactly?

It's strange...

Do you have any sugestions?

@james2doyle
Copy link
Member

Yeah. Here is my snippet I tested.

{% for page in pages %}
  <article>
    <h3>{{ page.title }}</h3>
    <p>{{ page.content|striptags|limit_words }}</p>
  </article>
{% endfor %}

I tried it without the striptags as well. Still no errors. What version of PHP are you on?

@Frodox
Copy link
Contributor Author

Frodox commented Feb 2, 2014

Offtopic

I also noticed in error.log, that [error] the key date for sorting is deprecated use meta:date or any other meta tag

Using the meta:date resolve an error, but it's default line in config..
$config['pages_order_by'] = 'title'; // Order pages by "title" (alpha) or "date"

@Frodox
Copy link
Contributor Author

Frodox commented Feb 2, 2014

PHP 5.3.20

@Frodox
Copy link
Contributor Author

Frodox commented Feb 2, 2014

Oh, I think, it is a sort of anonymous function
and

Changelog
5.4.0 $this can be used in anonymous functions.

Am I right?

@james2doyle
Copy link
Member

I also noticed in error.log...

Yeah that needs to be added to the documentation too. We would also need to change all the default .md files. Something for the backlog.

5.4.0 $this can be used in anonymous functions.

Thats a possibility. Can you give it a test and see?

@Frodox
Copy link
Contributor Author

Frodox commented Feb 3, 2014

Can you give it a test and see?

Sure. I will do it right now.

@Frodox
Copy link
Contributor Author

Frodox commented Feb 3, 2014

Yup, on PHP 5.4.4 all works fine.

P.s. @james2doyle Thanks for great video 👍

@Frodox Frodox closed this as completed Feb 3, 2014
@james2doyle
Copy link
Member

Thanks. It seems like just that plugin needs it then. Strange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants