Membership Level issue in NationBuilder - membership

I have a website built in NationBuilder. There I needed to make another Membership level. I have done that. But the issue is that it is not showing in "Who can view this page" dropdown in page settings. Anyone has any idea how to do that.?
Thanks in advance

It seems you can't control who can view this page via membership levels.
From a NationBuilder FAQ, How do I set up a five-tier membership site:
In NationBuilder... being a member is a binary state: you either are
or you are not a member. While NationBuilder allows you to sell
various membership levels, the database doesn't recognize those
various levels as distinct and different from a permissions level.
That means that if you make a page viewable to "Members" it will be
viewable to all members, equally.
There's really no good workaround for this that's based on membership
level of which I am aware. You can, however, use conditional liquid
tags to display different content on a given page to logged-in users
depending on what tags their NationBuilder profile has. Since each
membership level can be configured to automatically tag people, this
method could be employed to display different content to individuals
who have different membership levels (or none at all).

You can accomplish this by editing the page template. For instance, suppose you wished to restrict a page to only users with MEMBER_A membership.
{% assign hasPagePermission = false %}
{% for membership in request.current_signup.memberships %}
{% if membership.membership_type_name == "MEMBER_A" and (membership.status == "active" or membership.status == "grace period") %}
{% assign hasPagePermission = true %}
{% endif %}
{% endfor %}
{% if hasPagePermission == true %}
{{ page.basic.content }}
{% else %}
{% include 'access_denied' %}
{% endif %}
I realise that your original post was six years ago, however I post this in the hope that it will be helpful to others (or indeed me when I forget how to do this and end up searching for this again!)

Related

Shopware 6: logo automatically in documents

Is there a way to automatically output the logo of a sales channel in the documents (invoice, delivery bill, etc.) without having to create a separate document for each sales channel?
Thanks for your help :-)
Unfortunately, I have not found an approach so far.
I think it currently isn't possible to differentiate between sales channels with the document settings in the administration.
You could create a media custom field for the sales channel, upload the logo there and then use the custom field in the document template.
Go to Settings > System > Custom Fields
Add a new set and assign it to Sales Channels
Within the new set create a new custom field
As type choose Media and think of a unique technical name
In the sidebar to the left go to the sales channel you want to upload a logo for
Scroll down to the custom fields of the sales channel and upload the logo with the new media custom field
Save the sales channel
Then you'll need a plugin to extend the document template. Within your plugin create the template extension e.g. at {pluginRoot}/src/Resources/views/documents/base.html.twig
with the content:
{% sw_extends '#Framework/documents/base.html.twig' %}
{% block document_header %}
{% if context.salesChannel.customFields.custom_test_media is defined %}
{% set media = searchMedia([context.salesChannel.customFields.custom_test_media], context.context) %}
{# #var item \Shopware\Core\Content\Media\MediaEntity #}
{% for item in media %}
<img src="{{ item.url }}" class="logo"/>
{% endfor %}
{% endif %}
{% endblock %}
with custom_test_media being the technical name of the media custom field you created earlier.
Here is a video how to change Shopwares Document Logos the easy way using the WYSIWYG Document Editor:
https://youtu.be/fGBMDmVMPvA?t=162
The easiest way to change your documents is by customizing them with the WYSIWYG Document Editor. The live preview will save you a lot of time and money in comparison to going back and forth 1000 times between making adjustments in your Twig Templates and generating new PDFs for testing.
Check it out:
https://store.shopware.com/appli81810362453/wysiwyg-dokumenten-editor-pdf-rechnungen-lieferscheine-gutschriften-stornos-designen.html
I am the developer, which created the WYSIWYG Document Editor Shopware 6 App. Feel free to ask me any questions about the App. I am happy to help you.

Shopware 6: How to display product name in breadcrumbs

We want to add the product name to the breadcrumb list when current page matches a product detail page.
Unfortunately, it doesn't seem like the product is loaded yet when the breadcrumb is rendered. We have tried using dump() to see what variables are available and nothing related to the product.
Where should I look in order to include the product name in our breadcrumbs?
Have a look at storefront/base.html.twig. There you will see, that currently the breadcrumb-template gets passed the context and the category. If you want to also use some product-information, you have to overwrite this block like this:
{% block base_breadcrumb %}
{% sw_include '#Storefront/storefront/layout/breadcrumb.html.twig' with {
context: context,
category: page.product.seoCategory,
product: page.product
} only %}
{% endblock %}
Then you can use product in the breadcrumb-template.

Render a link field inside a paragraph template drupal 8

I have a paragraph called link. In this paragraph there is a single link field that allows multiple values. In the paragraph-link.html.twig file I want to render all of the links added to the paragraph. Instead I get the same link duplicated as many times as the number of link values. So if I add two links, it renders the first link twice. I also need it to work with external and internal links. Currently it only renders the external links properly (but only ever renders the first one).
{% for item in paragraph.field_link %}
{{ paragraph.field_link.title }}
{% endfor %}
Thanks for the comments, the following is working for external links but not internal ones. Internal link URI renders as "internal:/"
{% for item in paragraph.field_link %}
{{ item.title }}
{% endfor %}
With the help of the comments I was able to get this working as I wanted within the paragraph template. Below is the working code for a Link field that allows multiple values within a paragraph field.
{% for item in paragraph.field_link %}
{{ item.title }}
{% endfor %}

Grav CMS: how to show/hide parts of the page depending on conditions?

The Grav's documentation clearly describes how a whole page or a folder could be hidden from unregistered users. It also describes how a whole page could be seen only by particular user groups.
But what about pieces of a page, let's say, some links or a private info I want to show on some conditions?
Ok, for registered users I found a snippet at Login plugin docs:
{% if grav.user.authenticated %}
content for registered users goes here
{% endif %}
But going wider - how can I show/hide pieces of a particular page depending on some custom logic in PHP code, i.e. not necessarily user related?
I'm thinking about a twig/shortcode plugin, something like:
{% if some.custom.condition.or.PHP.function %}
hidden content goes here
{% endif %}
or
[hidden_if_something] hidden content goes here [/hidden_if_something]
But not sure how exactly this should be implemented. So working examples would be appreciated. Thanks.
There is a recipe in the Grav documentation here. This provides an example of how to render the output of a PHP code result in a twig template.
In the example they create a plugin, and implement a twig extension providing access to a php function. They can then simply call that php function like in a twig template.
{{ example() }}
Following that example, you can implement whatever logic you would like in php, and call the function in a twig if statement.
{% if example() == true %}
your conditional output
{% endif %

Paginate Shopify blog with offset? (Liquid)

I'm trying to figure out how to paginate a blog starting at a specific offset. For example, the first page features posts 5-8, the second page 9-12, third page 13-16, and so on. This doesn't seem to work, but I'm looking for something along these lines -
{% paginate blog.articles offset:4 by 4 %}
{% for article in blog.articles
...
{% endfor %}
{% endpaginate %}
Are there any workarounds here?
I was trying to see if there's any way I could find a decent workaround in Liquid but there isn't, since you're offsetting a full page; it'd be perfectly possible to show 5-8 on the first page, but you'd need to show 9-16 on second page and so on and so forth. I'm afraid Shopify paginate won't help you here.
There could be specific workarounds for your situation; please give us more detail and we'll see. For example, if you always want to show the four latest blog articles on every page, and leave pagination handle the rest, a possible way would be to do something as per the following:
{% for article in blogs.news.articles limit: 4 %}
{{ article.title }}
{% endfor %}
{% paginate blog.articles by 4 %}
{% unless paginate.current_page == 1 %}
{% for article in blog.articles %}
{{ article.title }}
{% endfor %}
{% endunless %}
{% include 'pagination' %}
{% endpaginate %}
So outside of any pagination go through the handle to obtain the latest 4 to feature them, and if you're not on page 1, use pagination to print 4 more articles on each page.
If not, this is one of the scenarios where you should consider exposing your own service that internally calls and retrieves articles from the Shopify API as per your needs.
The offset should be specified in your loop parameters, not in pagination.

Resources