Using Django paginator with nested templates with different number of displays - pagination

I am working with Django Paginator to set up my list view. In my default list view I've used "paginate_by=12" and then I need to show links with drop down to paginate by 20 and all. The list view includes Grid View and List View templates. I am including the templates with grid and list view but I can't control pagination with different numbers. Simply I am using a single view and including multiple templates for that list view...but how to use different paginator size in different tempaltes when I've set it as paginate_by=20 in my class based list view.
View:
class ProductListView(ListView):
model = Product
paginate_by = 10
I tried using {% include 'listview30.html' paginate_by=30 %} but it didn't worked. How to use multiple pagination with a single list view.
Kindly advise.

I found the solution at https://pypi.python.org/pypi/django-pagination. I've tested it on different pages and it is working fine for me.

Related

Orchard Core CMS - Is it possible to get an existing content item, to be shown in another content item?

I've been struggling to show an existing content item to a another content item, what I can do as of now is just add the content part in a content item with using Flow and Bag, but the user really has to fill up the fields for these stuff. What I am trying to do here is for example make a styled 'button' (with the tags and such) with prefilled text in the button, then the user can edit it anytime within the content item it is called.
I am using orchard core with .net core 5.0
There are multiple ways to do this, the way I like to do it for styling is to make a content part with different fields, usually text fields and once the field is created, edit the field and change the editor type to predefined list, once this predefined list is created, one of them can be selected as default. Then add this content part as a part on the parent content type image of fields on contentpart image of predefined list
Another way would be to create a content picker field on an item, that's how you can include other content types on a parent item, I find this approach good for bigger content items (I.e. contentbanners etc) content banner content picker image
This approach is good but you have to use the contentitem filter (Liquid or razor) to get the content item as the parent content item only includes a reference to the content item and not the actual item.
{% for ContentItemId in Model.ContentItem.Content.ContentSections.Banners.ContentItemIds %}
{% assign contentSection = ContentItemId | content_item_id | shape_build_display: "Detail" %}
{{ contentSection | shape_render }}
{% endfor %}
The Third way, if you want content creators to add buttons etc in html editors etc would be via using shortcodes. shortcodes

Sending entry data to embedded template

I have a basic ecommerce site which has a products page, in which a full overview of the products is displayed, including thumbnails, brief description, etc. On the same page, and other pages on the site, there is a sidebar which lists the products by title only.
Since the sidebar is reused around the site I want to set this as an embedded template.
With this setup, must I retrieve all the products from the database twice; once in the main Products page, and again in the sidebar? Or is there any way to speed things up on the Products page by retrieving the entries once in the parent template and passing them to the embedded page?
For example:
products parent template:
<html>
{exp:channel:entries channel='products'}
// display full product info
{/exp:channel:entries}
{embed='includes/_products_sidbar' data={entries}} // ^ Can I pass all the data from the above loop to this embedded template?
</html>
embed:
{if data}
// if we already have the data available then use it without having to get it all again from the database
{else:if}
// if not then use another entries loop:
{exp:channel:entries channel='products'}
// display a list of products
{/exp:channel:entries}
{/if}
I think you are better of using a different approach. Have a look at layouts:
https://docs.expressionengine.com/latest/templates/layouts.html
or, if that's not possible, you can use stash https://github.com/croxton/Stash too.
oh yeah, you'll get better help on https://expressionengine.stackexchange.com/

Custom rendering of a taxonomy - without using HTML lists

I have a multi-layer taxonomy that I want to display in a Bootstrap 'row/column' layout. How do I stop Orchard from rendering it as an HTML list?
At present I am having to create alternates at quite a high level. So far:
1. Parts.TaxonomyPart-url-MyTaxonomy
2. TaxonomyItem-MyTaxonomy
3. TaxonomyItemLink-MyTaxonomy
The first is required to remove the main <ul> that is automatically added by Orchard.
The second removes the <ul> from any child terms
The third handles the display of the actual taxonomy term (my custom HTML).
It works, but I'm sure there's a less cluttered way of doing it that I can't see.
I would prefer to alter the rendering of the taxonomy this way rather than create a projection, as I find projections don't handle taxonomies with hierarchies very well / easily.
Any help / suggestions would be much appreciated! Comment if you need more info.

Custom search result page in shopware5

I need to create a custom search result page for my Shopware site. As I know custom pages can be designed only for detail and list pages.
However, after creating custom list page for my site with the name of “custom_listing.tpl” my search result page is still looks like the default list page of the site. How can I get rid of this default list page template on my search result page?
I tried to change the fuzzy.tpl {include file='frontend/listing/listing.tpl'} to my “custom_listing.tpl” but that did not work.
What you need to do is to create your own theme/template and activate it in the Shopware backend. Further you need to create your own frontend/search/fuzzy.tpl in your theme folder.
Now let your own fuzzy.tpl extend from the original one like so:
{extends file='parent:frontend/search/fuzzy.tpl'}
After that you will have access to all the smarty blocks that are defined in the parent fuzzy file and even in the frontend/index/index.tpl of which the parent fuzzy extends from.
Make your changes, deploy it to your localhost or webserver and after clearing the cache the search controller should autoload the overridden fuzzy.tpl with your custom search results layout.

How to create Layout Based on Layer in Orchard

I am trying to create a different layout for a sub-section of my website using Orchard.
Let's say I wanted to give www.site.com/Shop a different layout from the rest of the website; how would I go about doing this?
I have tried looking for a way to do this using layers but have got stuck.
There are several ways to achieve different layout, since I don't know your specific needs I'll throw in some extra possible routes
Use url shape alternate (I guess you need this one)
You have to enable Url Alternates module and it lets you create shape alternates based on url. For example if your page is www.site.com/shop you can then create view under your theme Layout-url-Shop.cshtml and it will be used instead of default Layout.cshtml on your shop.
Orchard documentantion: URL and Widget Alternates
Use 1.x or wait for 1.9
There you can define dynamically different layout per content item aka page. But I find it good only for content not the base layout which is present in layout.cshtml
Create minisite
How to create a minisite inside your Orchard website

Resources