Not sure I have the correct terminology here. I'll explain what I want to do and you guys can tell me if it's possible.
I'm using MediaWiki as a Customer List page. So, I have a category for customers, and for instance, I have 20 customers. Inside the actual customer page I have several "headings" that make up the customer page, including an infobox. What I'm wanting to know is, how I would go about "including" the headings as a template "Customer Landing Page". Meaning, each "Customer Landing Page" (Customer A or Customer B, etc, etc) has the same "headings", but not the same content - so all I want is that each customer page, I can include a "template" and it has the same headings with no content under the headings - so that each time I change this "template" file, it changes it on every customer, and all I have to do is edit the content on the customer page that is required.
You'll have to make one big template for the entire customer page, in which you put all the info. I'll make an example template for a page with two headers, "Customer Landing Page" and "More info". The headers are fixed, and the contents below it vary between customer page.
First, you make the template by creating the page Template:Customer
In here you put:
=Customer Landing Page=
{{{landingpagetext}}}
=More info=
{{{moreinfotext}}}
The triple accolades indicate the variables you will later define in each customer page. For customer A:
{{customer
| landingpagetext = This is the landingpage for customer A
| moreinfotext = This customer is a vegetarian
}}
Customer B:
{{customer
| landingpagetext = This is the landingpage for customer B
| moreinfotext = This customer likes Tom & Jerry
}}
The double accolades indicate the start of a template, and the first word is the templatename used. Then after each pipe ( | ) you can assign variables. I only used newlines to make it easier to read, you don't have to do that (but it makes it easier to maintain).
If you don't use the variable names (like {{customer|Landing page text|More info text}} ) you can access the variables by the order they are defined in, using {{{1}}} and {{{2}}} in the template.
If the customer pages are really big you might want to split the template up and use one per section.
Another option (but more complex) is the use of Navboxes. This requires a lot more set up but mayb be closer to what you are looking for?
You could look at using MultiBoilerPlate, I use this to set default text in pages. I would call this a template but Mediawiki uses that term for something else. If you just want to load the same default text when you start a new page and then fill it in with your own text, then I think this is what you need.
Related
I really struggled to explain my problem and the only way I found it would be possible is - through screenshots as I have a lot of code and I am not sure what is really needed here. So if you want any code, tell me I will add.
The numbers on the pictures indicate the order.
Choosing the category
Selecting the category it redirects me to - /products_list?category=(that category_id)
Filtering through brand in that category
Now please pay attention to the URL and what happens after I have chosen the brand I want to filter with.
Back on the first page
Problem is here:
Now I am back on the first page, where are all the products but I wanted it to stay on that URL where are that kind of category products.
What I wanted to happen? Instead of it taking me to the page where are ALL the products and then doing the filtering, I want it to stay on that category page and return the filtered products there.
The brand dropdown menu also should only show that category products that I am in, not all.
You need to pass the other parameters as well. So that means that for two parameters category_id and brand, you create a URL that looks like:
{% url 'product-list' %}?category={{ category_id|urlencode }}&brand={{ brand|urlencode }}
If you thus already filtered the category down, you pass the category_id to the template, and render the URLs with the ?category={{ category_id|urlencode }} part.
Suppose you have a database with User objects running behind a Djano app
and you want to use django-taggit to tag User objects so you can retrieve subgroups using some convenient filtering.
Additionally you have a Dashboard where you want to display interesting statistics about used tags to glean some information about the subgroups that exists within your Users.
How would you access and display information about the top X tags
used within the Django app?
How would you access only the top X tags of an already filtered
subgroup of the User object?
While there are already a number of posts on SO that describe similar problems most of these describe workarounds or contain scattered information.
In order to make this information easier to find I will post a simple rundown of how to achieve some basic stuff using features of django-taggit that are officially supported but are not present in the official documentation.
How would you access and display information about the top X tags
used within the Django app?
In order to access and display information about the top tags used within the Django app you can use the built in function most_common like so:
top_tags = User.tag.most_common()
This returns a queryset containing all of the tags placed on a User instance ordered from most used descending order.
So say we have 3 tags: ["vegetables", "fruits", "candy"] and 10 users have a fruits tag, 4 users have a vegetables tag and only 1 user has the candy tag the returned order would be: ["fruits", "vegetables", "candy"]
Accessing more information about the tags returned can be done like so:
for tag in top_tags:
print(tag.name) #the name of the tag
print(tag.num_times) # the number of User objects tagged
Additionally if you are only interested in the top 3 tags then you can
access them like this:
top_tags = User.tag.most_common()[:3]
Where you can replace 3 with X where X is the number of items you want returned.
How would you access only the top X tags of an already filtered
subgroup of the User object?
Since Jul 12, 2016 the most_common() function actually has some additional arguments that you can specify. First of all you can specify a min_count which filters out the top tags that fall below a certain threshold. As an illustration using the tags from the previous example:
top_tags = User.tag.most_common()[:3]
returns all three tags as specified earlier but using
top_tags = User.tag.most_common(min_count=2)[:3]
only returns ["fruits", "vegetables"] this is because only 1 User object was tagged with candy meaning that it falls below the min_count of 2
An additional argument that you can provide to most_common is extra_filters this enables you to provide an object containing additional filter values that you want to filter the tags by.
One usage example would be:
filtered_users = User.objects.filter(age=20, is_delete=False)
top_tags = User.tag.most_common(
min_count=1, extra_filters={
'user__in': filtered_users
}
)
Here we create a filtered queryset of User objects that we then provide to the extra_filters argument to limit the tag search to a specific subgroup
I have a list of page names such as below:
Homepage
Product 1
Accounts
Sign In
Product 2
Campaign
Product 3
I want to use a calculated field in Google Data Studio to aggregate all Product pages. How would I write the code so that it still includes the other pages without manually inputting each individually? This is the code I have:
CASE
WHEN REGEXP_Contains ( Page Title, 'Product' ) THEN "Product Page"
ELSE [LEAVE AS IS]
END
What code would I write to leave the page title as-is but still including it? I feel like it's either something so simple or impossible and that's why I've been unable to find any answers. Would really appreciate any help!
I would guess just this:
CASE WHEN REGEXP_Contains ( Page Title , 'Product' ) THEN "Product Page" ELSE Page Title END
Is there a way by using XPath Builder under Developer Center inside Sitecore Shell (a Fast Query interface) to select a particular attribute from an item. Example:
/sitecore/content/Home/Products/*[##templatename = 'Product Group']/#id
I would expect to see a collection of id's to be returned where id is an attribute of an item. If yes is it possible to extract an attribute with a space bar? Example:
/sitecore/content/Home/Products/*[##templatename = 'Product Group']/#more info
EDIT
The thing that I want to achieve is to get a collection of items (I have few hounded items here), not one particular item. That's why I am not interested in adding additional conditions, like specific item id or title. I want to see a collection of values of a specific attribute. As in example showed above, I want to see a collection of values that are assign to 'more info' attribute. Once again I am expecting to see few hounded different values that are set to 'more info' attribute.
EDIT2
There is a problem with a production, a critical stuff. There is no access to it other then thru Sitecore shell, but I don't have permissions to add/install additional packages. I know how to get this info by implementing custom code, or queering db directly, but I simply do not have permission to do it. Guys that will be able to grant me need credentials will wake up in 6 hours, so I was hoping to do whatever I can to analyse the situation. I would accept Maras answer if it was an answer not a comment - there is no way I can do it using fast query. thanks for help.
Try using #
/sitecore/content/Home/Products/*[##templatename = 'Product Group']/##more info#
This is the way around when selecting items with fields that contain spaces. Having said that I don't know if you would be able to get a specific result or not for your specific question but give it a try.
For example, consider this query which returns Product S1
fast:/sitecore/content/home/*[#Title = 'Item 1' and ##templatename = 'Product Group1']//*[#Title = 'Product S1' and ##id = '{787EE6C5-0885-495D-855E-1D129C643E55}']
However, if you place the special attribute (i.e. ##id) at the beginning of the condition, the query will not return a result.
fast:/sitecore/content/home/*[##templatename = 'Product Group1' and #Title = 'Product S1']//*[##id = '{787EE6C5-0885-495D-855E-1D129C643E55}' and #Title = 'Product S1']
Remember this, Sitecore Fast Query only supports the following special attributes:
##id
##name
##key
##templateid
##templatename
##templatekey
##masterid
##parentid
Let us know if this helps.
I want to have a content entry block. When a user types #word or #blah in a field, I want efficiently search that field and add the string right after the "#" to a different field as a n entry in a different table. Like what Twitter does. This would allow a user to sort by that string later.
I believe that I would do this as a part of the save method on the model, but I'm not sure. AND, if the #blah already exists, than the content would belong to that "blah"
Can anyone suggest samples of how to do this? This is a little beyond what I'm able to figure out on my own.
Thanks!
You can use regex (re) during save() or whenever to check if your field text contains #(?P<blah>\w+) , extract your blah and and use it for whatever you want .