I want to ask if it is possible to make WP archives page that arranges the custom posts in specific way. Let me explain.
The CPT is "Products". All the products have several custom taxonomies. Ex.
Product>Fall 2014>Shampoo (there is only one shampoo from this Fall 2014 collection)
Product>Fall 2014>Conditioner (there is only one conditioner from this Fall 2014 collection)
I want to add the corresponding Winter 2014> Shampoo and Winter 2014 > Conditioner but I want to be able to display them in the following order (masonry style):
Fall 2014:
Shampoo Conditioner
Winter 2014:
Shampoo Conditioner
Also I want to be able to categorize them by product type like:
Shampoos
Fall 2014 Winter 2014
Conditioners
Fall 2014 Winter 2014
In the end to explain the relation between the taxonomies and CPT.
Shampoo1( Custom post type - Products) which has the taxonomies Shampoo (parent taxonomy) and Fall 2014 (child taxonomy).
Is something like this possible to be made so the process of sorting will be made by wordpress with each new product, and if it is possible can someone point me in the right direction because I am lost :)
Yes, you can. By creating custom taxonomy templates for all your taxonomies and so your posts relevant to certain taxonomies will be showing up in your taxonomy template. For example if your custom taxonomy is Shampoo, then your taxonomy page will become taxonomy-shampoo.php in this way you can create templates for all other taxonomies to show your products according to your needs, for reference check https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/
Related
How to get links of some Sharepoint Query to a central place
I am facing an interesting problem. For an application, I need to collect links (and some metadata/properties: year, company_division, type and date_document_modified) from a large number of Sharepoint sites based on some query mechanism, and subsequently put them in a Sharepoint list at a central location on some central Sharepoint site. Connected to this Sharepoint list will be a Logic App that has a trigger task of ‘when an item is created or modified’ on this list. Note that the ability to use of LogicApp on a list of links is a must in the solution, sadly I’m bound to this, and thus not looking for alternative solutions.
To do so, I want to query the whole of a certain Sharepoint environment where I want to i.e. get all document urls, year, company_division, type and the date_document_modified for a query like ‘type:"notes" company_division:"division1" year:”2020”’, and get these properties automatically transferred to a list based on this query. Is there a possibility to do this from just the general Sharepoint GUI? So the flow is: Query -> Results -> Output to some Sharepoint list. If no, is there a programmatic way to achieve this kind of solution (I would much rather prefer a non-programmatic and simplistic way though)? Output in the list would have to look basically like this:
document_url
type
company_division
year
date_document_modified
url1
notes
division1
2022
22-09-2022
url2
notes
division1
2022
22-09-2022
document_url type company_division year date_document_modified
url1 notes division1 2020 22-09-2022
url2 notes division1 2020 22-09-2022
Also, I would like to be able to automatically schedule the Sharepoint query to run once every X days in some way or another (preferably using the Sharepoint GUI, but otherwise maybe with PowerAutomate or something). With this, I would also – if possible – like to be able to modify list elements, for example when a new entry is added that has the same url, type, company division and year, but has a new ‘date_document_modified’.
Is there any way to achieve this without too much programmatic hassle and if not, are there programmatic ways to achieve such a scenario?
I want to model menus composition in a Restaurant. I've created a very small Bounded Context around just 3 concepts: Menu, Category, Product.
Menus are composed of different Products and every product in each menu is placed under a certain Category (a category is for example, "entrants", "1st course", "2nd course", "dessert"…).
The problem is that everything seems like an Entity to me.
For example, when a Menu is deleted, no Products or Categories are deleted. The same happens when the other 3 concepts.
Regarding the UI, Menus will be consumed like a hierarchy:
Menu1
Category1
Product1
Product2
Category2
Product3
Product4
I'm wondering how to model this. Should I make them 3 Aggregates? Then, how should a compose a Menu in order to be consumed like the hierarchy above?
Thanks.
If you have a menu as an aggregate root with your current arrangement, then what would happen if you wanted to re-use the same product on a different menu? From outside the aggregate root, you wouldn't be able to hold a reference to it.
Instead I think that having Menu and Product (ask the Chef what he would call a food or menu item!) as aggregate roots are fine, as they both exist and have their own identity (you may have different menus over time, a menu may consist of food items that have been used on other menus).
Having the Category as a value object may be more fitting (again, maybe a Chef would call this a Course?) - how many Categories do you have (I believe these courses are probably fixed)? Does a category have its own life-cycle and identity? An enumerable on each product could fit this requirement well.
You also mention about deleting... that sounds like a technical infrastructure term. There are two issues with this:
If you did the above and split in to two aggregate roots (Menus and Products) how would you handle a delete of a Product when a Menu is referencing it? This becomes a transaction across two aggregate roots, which are hard to implement (one of the main ideas of DDD is defining transactional boundaries and enforcement of invariant via aggregates - any external operation on an aggregate root from the outside should leave it in a consistent state).
Think about what the chef or restaurant manager would do - would they delete a menu, or would they instead archive it or make it no longer available for selection?
One resource that will help solidify the above is Effective Aggregate Design by Vaughn Vernon - http://dddcommunity.org/library/vernon_2011/
In terms of code, a psuedo mockup in C# would be below:
public Object HandleGetMenuCommand(
string menuName,
IMenuRepository menuRepository,
ProductRepository productRepostiory)
{
Menu menu = menuRepository.Get(new MenuId(menuName));
List<ProductIds> productsInMenu = menu.Products;
List<Products> products = productRepostiory.GetMany(productsInMenu);
List<string> categories = ... // get a list of unique categories from products
// now assemble products by category...
foreach(var category in categories)
{
var productsInCategory in products.Find(x => x.Category == category);
foreach(var product in productsInCategory)
{
// add this to a list...
}
}
var clientData = new {
name = menu.Name,
// add in the products that were assembled by category above
}
return clientData;
}
I think you are trying to make too much effort putting everything into DDD instead of making focus of the simplicity about this domain by just looking into the "real world. Please let me first go with an plain OO approach and just then let's talk about how to see it with DDD.
So you wanna have Menus so restaurant customers can look at them and choose whatever they want to eat. Let's suppose at the moment there will be just 1 menu for lunch, dinner, every weekday.
The restaurant manager should be able to create this Menu and change it whenever he wants to.
This is our first use case
menu = new Menu("monday lunch", starters, mainEntrees, desserts, drinks);
where each of those parameters are lists of value objects (at first sight).
Just take a look at the real world, a menu is a description of the food you can get in a restaurant, those descriptions are inmutable objects (value objects) so so far we do not need anything else.
At this moment we have only one aggregate root that is Menu. It has global identity and groups a cluster of objects and has invariant. What class would I use to model an entree, dessert? String... an instance of String is enough so far.
What about the menu? We could have many Menus, one for monday, one for tuesday, one for friday night and so on, each having its own global identity so we have for sure the MenuRepository.
What about if the restaurant manager wants to add a new dessert?
menu = menuRepository.get(menuId);
menu.add(aDessert);
is enough.
So far we have one Menu aggregate root and its repository.
I think this is what you asked.
However, I think you missed the price. Each line on the menu would have prices, and two same desserts on different menus may have different prices if its lunch or dinner, so a more realistic approach seems to be:
menu = new Menu("monday lunch", starters, mainEntrees, desserts, drinks);
where starters, mainEntrees, desserts, drinks are a collection of type MenuLine.
Now what happens if the customer tells the waiter to bring him something to eat? a new order needs to be created to keep progress of what the customer asks in order to create an invoice later.
this order needs to know what food the customer asks, I mean what menu item the customer orders. So far we are using value objects to model the desserts, drinks, etc. Right now we should give some form or identifier to those options the customer can choose in order for us to have some unique identifier to use in order contexts such as orders. This is where we determine we need another Aggregate Root (the one you called Product). I would rather call it Food or something like that.
So when the restaurant manager decides to let the restaurant offer a new food the system would be
food = new Food("sushi");
foodRepository.add(food);
and then we the manager wants to add sushi to the menu of monday night
food = foodRepository.getBy(foodId);
menu = menuRepository.findByCriteria(mondayNight)
menu.addAt(food, tenDollars);
and what Menu does is
addAt(food, tenDollars) {
mainEntrees.add(new MenuItem(food.id, food.description, tenDollars)
}
we do not want the Menu to hold a reference to the Food aggregate root because of what vaughn vernon said in its book.
well hope it is helpfull. You do not need the concept of Category at all:
Menu {
List starters;
List entrees;
List desserts;
List drinks;
}
Hope it helps.
Cheers,
Sebastian
I want to create a view where all 5 of my taxonomy terms are displayed and it then displays the latest node published but this is limited by 1. For Example:
Tax Term 1
Latest node published
Tax Term 2
Latest node published
etc etc
Currently I'm grouping by taxonomy term so it's displaying all nodes published then sorted by published date desc. I can't quite figure out how to limit the nodes to only show one item per taxonomy term.
Any help would be greatly appreciated.
This is possible with Views 3. I've tested this on D7, but should work on D6 also.
Add a new view of type - Taxonomy terms
Add relationship - Taxonomy term: Representative node
Other - Use aggregation: Yes
Add field - Content: Title. Change Aggregation settings to Group results together
It's not great if you have a lot of nodes, but I've done this in other cases by using a filter for "Promoted to front page" - then you simple make sure you only promote one node at a time.
I'd suggest to use a combination of panels ans views.
First, create a (or use the default) view for nodes which takes a taxonomy term as argument. Second, create a panels page containing five regions. Each region is to be filled with a view (in fact it's going to be the same view from step one, but with different arguments). Within panels ui you can restrict the number of shown entries of each view, set this value to one to have only one article be shown per term.
Panels: http://drupal.org/project/panels
Views: http://drupal.org/project/views
I'd recommend checking out the Views Group By module.
http://drupal.org/node/389230
The tutorial listed above actually describes almost exactly what you are trying to do.
Our company is split into divisions. These divisions work for client companies and are then further split into account teams that work on projects for a product of the clients.
So the structure goes Division > Clients > Accounts > Projects. And this is mirrored in the setup of our sharepoint installation. At each stage from Division to Account there is a subsite. Access to each subsite is controlled by AD groups and on each subsite there is a 'latest news' announcements list
What we want to do is have a 'wall' of announcements that feeds through so that each user can see on the top-level site all the posts in all of these anouncement lists, but this must be filtered using the AD groups that they are a member of so that confidential information isn't shown to someone who shouldn't see it.
Can anybody think of a way to do this?
Let's see - are those lists split accross site collection? With what tool you want to accomplish this?
You have several options (if you are within a site collection):
Use Content Query Web Part to
aggregate list items. You can
customize it to display fields
you like the way you like.
You can use SharePoint Designer.
Using Object Model/WebServices: Use
SPSiteDataQuery class to query
multiple lists at once and then
SPGridView to display data.
As you have a MOSS build, you could
even use CrossListQueryCache.
It's also a cross list query that
has builtin caching and audience
targeting. Be sure to read this to be sure caching is working.
If you want to aggregate between multiple site collections, then you will need to write code that get's all your SPSite objects and execute SPSiteDataQuery on them.
Maybe you can find out some additional information on Rollup of all Tasks of a Recurring Meeting in SharePoint
Here is how we are doing it.
Set up a content type for each level of announcement. We have national, state, district and the basic site level announcements. Therefore I have 1 national content type, 10 state content types (because we are in 10 states) and 1 content type for each district. All of these content types inherit from the base Announcement type with no modification.
I added a content query web part. I exported it. I edited the XML in the .webpart file to point to a new custom ItemStyle_Announcements.xsl file I had created. I import the modified .webpart and delete the default Content Query Webpart.
I modify the ItemStyle_Announcements.xsl to create the structure and divs I need for the styling. I add styles to the default style sheet I have already created for my site to get the look and feel I want. (I happend to have two styles for these, one featured/most recent item which is big and full, then a listing the next 10)
I find an announcement list that will possibly post to the national new. I add the content types as needed. Now the end user can choose what scope of announcement they want from the New menu.
This remaining issue is that right now, the States and Districts must have TWO announcement webparts on their home pages. One that lists everything local to that site (regardless of scope) and one that has unit announcements aggregated from the other sites in the same state / district.
I have a SharePoint document library that has a folder structure used for organizing the documents (but also for controlling access, via permissions on the folders).
The documents in the library are updated every month, and we store every month's version of the document in the same folder; there's a "month" column used for filtering that will contain values like Jan 09, Feb 09, etc. It looks like this:
Title Month
----- -----
SubFolder 1
SubFolder 2
[] Interesting Facts Jan 09
[] Interesting Facts Feb 09
[] Interesting Facts Mar 09
[] Fascinating Numbers Jan 09
[] Fascinating Numbers Feb 09
...
Now, because users will generally be most interested in the 'current' month, I'd like them to be able to apply a filter, and select (say) Mar 09. However, if they do this using the built-in filtering, it also filters out the folders, and they can no longer navigate the folder hierarchy. This is no good - I want them to be able to move between folders with the filter intact, so that they don't need to keep switching it off and on again.
I figured I might be able to use a custom view (selecting where type=folder or month=[month]), and to an extent that does work. However, I can only get it to work for a fixed month, whereas I need the user to be able to select the month - perhaps via a drop-down control on the page (and I don't want to create 60 views for 5 years' worth of months, nor do I want to have to create a new view every month).
I thought it might be possible to create a view in code (rather than via the UI), but I've not been able to figure out how to get a dynamic value (a user-specific setting) into the CAML query.
Any pointers gratefully appreciated! And by the way, I am aware of the dogma that folders are bad, and that everything should just be a list. However, having considered the alternatives, I still favour using folders - if I can solve this problem.
Thanks in advance.
Could you create a content type that inherits from Folder that contains a Month column? Then, replace the normal folder content type with your new one on this list. Set the month appropriately, and now your filter would contain the folder as well.
You might like to try using a DataViewWebpart filtered by a form webpart to do this.
Managing the display of the folders and then the folders items when it is clicked on will be a problem. That is one of the reasons for not using folders I guess.
I'm currently experiencing the exact same issue, instead of a simple date, I need to filter based on folder names and then then show those folders on the page. Once they click a folder they will then be able to view the content of that folder.
I haven't found a good solution for this just yet, but for yours, you should be able to simply create a custom CAML query using the contentQueryWebpart.
Something like this:
Further Customize CQWP
But you would do it on the date/time of the folder and nothing else.
Your query would be something like:
<![CDATA[
<Where>
<Gt>
<FieldRef Name="Created" Nullable="True" Type="DateTime"/>
<Value Type="DateTime"><Today /></Value>
</Gt>
</Where>
<OrderBy>
<FieldRef Name="Created" Nullable="True" Type="DateTime"Ascending="FALSE"/>
</OrderBy>]]>
I would add also the name of the folder you're looking for to make sure nothing else gets returned.
Hope this helps. And please do postback if you find another solution.
I think I found your solution - The DataWebPart is actually what helped me....
Using this also was a huge eye opener:
ASP.NET Controls Filter Data View
To summarize it, you can simply populate your dropdown with the month year combo, add the shared Doc library on the page via the designer view, use a 'filter' connection to your ASP.NET dropdown and pronto you have a filter on a per month.
You can also have it default to a certain date using XSL, it's all in the code-view now :)
#Gary
The Controls filter of the DATA view (my 2nd answer) actually does keep the folder hierarchy.
You can have it go into sub-folders if needed, but in your case you're only interested in showing one specific folder correct?
What you're doing is useing SP-designer to do it, I couldn't find a way to do it via the regular webparts.
drag and drop your shared document library in the 'design' view for the page
Click the common task arrow ( > ) and customize the columns you want to show
Still in the common task, apply a filter of choice. What you want to do here is apply a filter on your Month column, so that the Month column is equal to the current month/year, correct?
The filter will only give you a choice to type something in, type the current month, say May 09. then switch to 'code' view
Find the shared document library, and more specifically look for something like:
< ;Where> ;.... That is the CAML query I had mentioned before. You can do an HTML decode on the whole thing, so that it's a bit more readable.
But in essence, the filter is a simple CAML query.
You want to modify that query, so that your month/year combo is that of the current month/year.
CAML has one feature called <MONTH/> which returns the month in the following format: mm/yyyy (you may need to change the format on your column or create a new one to make it easy on yourself) - Your CAML query should be something a bit like this:
<Where>
<Eq>
<FieldRef Name='Month'/>
<Value Type='Number'><Month/></Value>
</Eq>
</Where>
or
html encoded:
< ;Where> ;< ;Eq> ;< ;FieldRef Name='Month'/> ;< ;Value Type='Number'> ;< ;Month/> ;< ;/Value> ;< ;/Eq> ;< ;/Where> ;
The key to this, is that you're only creating a filter at the root level, on the data view. Once they click on the folder, they're just thrown into the document library and can view everything within the folder.
Hope this help!
ps: on the html encoded I had to add spaces before the ';' so you could see the code.
I have worked a great deal with filtering and the SPGridView. Maybe you can get something out of looking into this post on my my blog.
As I said, don´t know if it will help you but have a look.