Show total number of items in a PyroCMS Stream in menu item - codeigniter

I'm using PyroCMS Pro 2.2.6 and I would like to show the total number of items in a PyroCMS Stream in a menu item; specifically I would show dynamically the number of reviews in database.
I tried various things that didn't work:
1.) I added an Entry Looping tag (http://docs.pyrocms.com/2.1/manual/plugins/streams/entry-looping) which was cut because the menu item field isn't large enough:
{{ streams:reviews where="review_status='1'" }}{{ total }}{{ entries }}{{ /entries }}{{ /streams:cycle }}
2.) I used the Variable module and created a variable for the Entry Looping tag which I added to the menu item: {{ variables:reviews_total }}. In the menu nothing was shown.
3.) I used the Widget module and created a widget instance for the Entry Looping tag which I added to the menu item: {{ widgets:instance id="10"}}. In the menu nothing was shown.
That's how the menu should look like whereas "23" should show the number of records in my stream:
Any ideas how I can solve this?
Many thanks,
Philip

Related

How can I sort the featured blog posts in the top of the list in Octobercms

My request is simple. I want to keep my blog list ordered by created_at DESC but I want also to show the featured posts in top.
Let's say that I have 4 categories : Gold, Silver, Bronze and Other ...
I want to display the Gold posts first.
Then the Silver posts.
Followed by the Bronze posts.
And finally the others.
All of them should be ordered by created_at DESC.
Is there a feature out of the box to do that ?
Or should I create a new plugin to extend Blog with this feature ?
What do you think ?
I am assuming you are using the Rainlab Blog plugin. There are numerous ways to solve this and I don't think there is an official "way". Here are some examples that you will have to fit for your own code.
Solution with Twig. Twig has a sort filter which you can pass in an
arrow function, check
here. Then you
can do if statements to display gold to bronze.
{% for blog in blogs|sort((a, b) => a.created_at <=> b.created_at) %}
{% if blog.category == Gold %}{{ blog }}{% endif %}
{% endfor %}
Adhoc CMS
Page. Instead
of using the rain blag component you can use the plugin in the PHP
Code to the page/layout/partial. This is where give you the ability
to work with the model to organize it the way you want to. Here I am
using OctoberCMS querying
features.
use Rainlab\Blog\Models\Post;
public function onStart() {
$this['golds'] = Post::whereHas('categories', function ($query) {
$query->where('name', 'Gold');
})->get()->sortBy('create_at');
}
Third way and the way I recommend is to build your own plugin which
can either extend or filter the blogs posts like how I did in the
CMS Page example. Read the documentation here.
One side note that if you click into the {% component 'something' %} you can expand the htm template.

NetSuite- Advanced PDF Template, How Can I get Each Item's Component Information Through Salesorder Record

I am trying to customize a pdf template so I can print my own Picking Ticket. I can get all salesorder's information/data by use ${record.[fieldId]}, and I can also get all items' general/header information in the current salesorder's record using ${item.[fieldId]}. However, can anyone tell me how to get each item's components list through "item.[...]"
I tried to use "item.member", where member is the components list of each item, and it always said "item.member" is not a sequence or list.
Any idea? Thanks,
You can print this information with NetSuite's new Saved Search printing feature that was released in 2017.1. Make an item saved search with Member Item being one of the results. Then create a template from the saved search with the "New Template" button. Use this tag somewhere in your document:
${result.memberitem}
See SuiteAnswers article "Advanced Templates for Printing Saved Search Results" if you want to learn how to print all results on one page.
You don't need record - just use ${item.[field]}
You'll notice in the source code at the start of the item list table it has <#list record.item as item>

Generate Markdown Posts in Jekyll and Made Available to Paginator Variable

Is it possible to generate a set of posts in _posts as Markdown files in a way that they are treated as if they had been manually created and therefore, available to the process of creating the site pagination? I found examples of how to generate pages in various places like this SO question, but they seem to put the rendered content in _site and displaying the {{ paginator.total_pages }} variable does not yield any value.
Yes its possible to add "dynamic" content using a generator plugin.
You can generate pages, posts, collection's items, static files, anything you want.
For the {{ paginator.total_pages }} returning nothing. The paginator variable will only be available in your pagination template and nowhere else.

Passing a YAML frontmatter variable from a page to a collection in Jekyll?

So i have a collection called components. The components are a series of small HTML objects with some data in.
I want to pull these components into a page, and be able to pass overriding YAML frontmatter from the page into the component to determine a couple of things on the component.
Is this possible?
I'm pulling specific components onto a page using the following syntax:
{{ site.components | where:"component_name","event-title" }}
but i'd like to be able to do something like:
{{ site.components var-page-state="offline" | where:"component_name","event-title" }}
I chose to use a collection than a series of includes, as i need to loop through the collection and generate/render an index page of all of the components on it automatically.
EDIT:
So i want my component to be able to output a variable set on the page it's included on.
component.title.html:
<h2 class="title">{{ page.var-page-status }}</h2>

Go HTML templates for multiple sites

I'm preparing an application that will serve several different sites that have a common admin panel (a page with different themes to simplify).
Each of these "themes" will have different needs. For example while all of them show a list of services, some of them will show an associated image too. For the ones who don't I would prefer to avoid the DB calls to fetch them (different logic to render the pages).
In Laravel (a PHP framework) this would be a perfect use for view composers.
What would be the design of such a system in go?
I was thinking in some kind of "hooks" that each theme can register to run functions to fetch and add data for a specific template. There's a better way to do it?
If you pass a list of service objects to the template, you could easily decide inside the template what you want to show. If you decide to show a service's image, you could call the ServiceObject.ImageURL() (which would then lead to a database call). If you're not calling this function, there will be no database query issued.
A sample using the pongo2 template engine:
{% for service in services %}
{% if page.theme == "simple" %}
<p>We don't show any image in the simple theme.</p>
{% else %}
{# This would lead to a database call and return the image path #}
<img src="{{ service.ImageURL() }}" />
{% endif %}
{% endfor %}
Another idea would be to simply create an individual template per theme (extending the common base template); you don't have check for the theme inside the template then.

Resources