Load component on Taxonomy page #463
|
Hi there, |
Replies: 4 comments 4 replies
|
Is there any movement on this? I'm currently experiencing the same issue |
|
Currently, I get not exactly what should be produced exactly. Can someone describe the purpose and the goal more clear for me? Is the main goal to render a static component before or after the “loop” of posts on taxonomy pages? Or should taxonomy pages get a flexible content field like posts, pages to adjust its content? @comsup did you found a solution for your purpose? |
|
Hello Ben, On functions.php : // getting datas of the products : ---------------------------------------------------------------- return $data; // And on the twig : {% endfor %} |
|
Thanks for the feedback. The solution from @comsup seems to break out a little bit of timber. What do you think about this approach:
add_action('Flynt/afterRegisterComponents', function () {
ACFComposer::registerFieldGroup([
'name' => 'nameOfTheTaxonomyComponents',
'title' => 'nameOfTheTaxonomy Components',
'style' => 'seamless',
'fields' => [
[
'name' => 'nameOfTheTaxonomyComponents',
'label' => __('Page Components', 'flynt'),
'type' => 'flexible_content',
'button_label' => __('Add Component', 'flynt'),
'layouts' => [
Components\BlockWysiwyg\getACFLayout(),
]
]
],
'location' => [
[
[
'param' => 'taxonomy',
'operator' => '==',
'value' => 'nameOfTheTaxonomy'
]
]
]
]);
});
use Timber\Timber;
use Timber\Term;
$context = Timber::get_context();
$context['term'] = new Term();
Timber::render('templates/nameOfTheTaxonomy-taxonomy.twig', $context);When you are using the flnyt next branch, step 2. shouldn’t be necessary, because it uses the Timber 2.0.0-beta.1 and the term will added directly to the context.
{% extends contentOnly ? 'templates/_contentOnly.twig' : 'templates/_document.twig' %}
{% block content %}
{# In my test meta did not work #}
{% for component in term.nameOfTheTaxonomyComponents.nameOfTheTaxonomyComponents %}
{{ renderComponent(component) }}
{% endfor %}
{% endblock %}Hope this helps and let me know if it works for you? |
That works for me @timohubois,
I did have to make one change however, in the nameOfTheTaxonomy-taxonomy.twig, I removed the second
productCategoryTaxonomyComponentsin the for statement.However I can confirm we can both render the components and also show the blocks! 🎉
Additionally I've copied the reusableComponents into my project and that's also working great!
Thank you again!