MatissJanis / oc-testimonials

OctoberCMS testimonial plugin (Mja.Testimonials).
2 stars 6 forks source link

Expanding the Component in Backend Markup Causes Empty Results #7

Open billyzduke opened 8 years ago

billyzduke commented 8 years ago

I'm pretty new to OctoberCMS, but this week I've already managed to extend the User plugin and add some more db fields I needed... Having a very strange issue with your testimonials plugin.

If I drag the testimonials component into my code and leave it, I get the full list of testimonials displayed in blockquotes as expected. If I expand the component, or attempt to write my own code referring to "testimonials," I get no results returned whatsoever.

I'm not sure why this would be, but I did quite a bit of poking around and that is what is happening. I would like to be able to render the list items in my own templates, one in particular needs a single, randomly selected testimonial.

MatissJanis commented 8 years ago

Hello @billyzduke

Would You mind sharing Your own code that You were referring to and that wasn't working?

billyzduke commented 8 years ago

Well, here's one of the versions I've tried replacing the component with that doesn't work, but as I pointed out, YOUR code also doesn't work if I expand the testimonials component in the CMS backend and resave the file that includes it. That's the part that's not making sense to me, as it should be the same code, expanded or not.

`{% for testimonial in testimonials %}

  • {{ testimonial.content|raw }} {% if testimonial.author %} {{ testimonial.author }} {% endif %}
  • {% endfor %} `

    Note that the misspelling "testimonails" in the div class is seemingly intentional, as it matches the stylesheet in the theme I am using.

    billyzduke commented 8 years ago

    I have gotten this to work finally, but I had to alter the code of components/Testimonials.php and put another variable name in there instead of $this->page['testimonials']. What is think is happening is because your component and your variable have the same name that the Twig renderer (or something else along the line on the way to compiling for display) is getting confused, because the different variable name works just fine with any template.