Page autolist by category?

I have a news section of the site where all news stories are saved in one directory. I was hopeful I could have our editor start associating categories with these articles, so I could then somehow create a page autolist, or something of the sort, to display this content elsewhere on the site. For instance, if he selects “sport management,” that article would appear in my sport management section, which is in a directory outside of news.

Any thoughts on how I might accomplish this?

Thanks.

Hey Brian,

There’s no function like this built into CM1 currently, but if you were to take advantage of our DTS API, you could essentially create your own Page Auto List that does what you describe.

For example, if you were to house the code below in an HTML widget, it would pull in a list of the ten most recent pages created in the “/myfolder” directory that are categorized as “Category1/SubCategory”:


  

  

 
-    
  
 
  

  

  

 
-    
Sample 1   
 
-    
Sample 2   
 
  

  

Things to note:

  • MyCM1Site must be replaced with your site’s name in CM1.

  • /myfolder/% must be replaced with the path to your news articles (the “%” character can be removed to limit results to only the folder specified, and no sub-folders).

  • /Categories/Category1/SubCategory must be replaced with whatever category you setup and assign to these pages.

  • http://www.mysite.edu/ must be replaced with you DTS connection URL specified in your delivery-servers.xml file located at {cm1_root}\rxconfig\DeliveryServer (which is typically just your root hostname, e.g. http://www.springfieldcollege.edu/).

Be aware that this will not function until it has been published to your live server. I’ve added in a Div with two sample links for styling purposes while viewing this in preview in CM1.

There are many options to control the output of this “custom” auto-list. You can reference our DTS API article here for more options, such as filtering by tags, templates, page title, limiting results to only one folder level, etc.:

http://help.percussion.com/developer/…

Let me know if you have any trouble setting this up.

Thanks! I’ve got a simple one working right now. Is there any way to include the page summary in the auto list, and do you know if there is there a way to sort randomly?

Hi Brian,

To include your page summaries in the results, all you have to do is include empty opening and closing Div tags below the empty Anchor tag in your perc-page-auto-list-structure Div, and our JavaScript will know to include the page summaries that it’s already pulling in. Here’s the relevant block of updated code:


  

 
-    
  

  
 
  

There’s no random sort function that I’m aware of, sorry.

Hi Nathaniel,

Do you know if there is a way to query multiple folders and categories for the DTS api? I have a list I’d like to create that would pull data from two separate folders.

Thanks in advance!

Hi Brian,

I’ve been playing with this, and it appears that our meta-data web application treats criteria for multiple folder paths and categories as AND filters, rather than OR filters. Meaning, you could filter for multiple folders and categories, but it would only return content if the same content existed in both folders and was tagged with the same category, which I’m sure is not what you’re looking for.

That said, I will keep toying with this when I have the time. I’ll let you know if I come up with anything that may be of use.

Thanks for your help. For my current need I think I can make it work, if you come up with anything, let me know and happy new year!

Hi Nathaniel,

Jonathan pointed me here. How would I re-write this to query by “Tag” instead of Category?

Hi Conan,

To filter only by tag, you would replace "perc:category = '/Categories/Category1/SubCategory'&quot with

"perc:tags = 'yourTag'&quot

Including both would filter by category and tag.

-Jon

I would like to use this for my blogs. I have yet to tag or categorize them, but I still want to show my most recent blog posts. If I remove the line(s) Jon stated above for category or tag, and use the blog folder, would this pull my 10 most recent blogs?

Thanks Jon!

I got the custom Page Auto List widget pulling in pages by Category AND Tag. However, I’m pulling pages from one of our sites into another. The links that get generated seem to be acting as Relative links, instead of an Absolute link that would jump it to the other site. Instead I’m getting a 404.

Any ideas?

John, in this case, you can use a basic Auto-List configured to point to your blog folder, and you wouldn’t have to touch any code (aside from some CSS to style the Auto-List, most likely).

Conan,

Unfortunately I don’t think there’s going to be an easy way to do this. One option would be to use jQuery to prepend to the href attribute, but you’d both have to set the code to trigger after AJAX updates the DOM (or on click of the links), and there would also have to be some unique identifier within the links so that you know which links to prepend to.

Alternately, if your site names within the CMS are also your root domain names, you could circumvent our Auto-List system entirely and develop your own JavaScript that queries the the DTS server and pulls back both the page path and site name to construct a fully-qualified URL for the href. Here’s the AJAX to pull in the JSON payload, but obviously there would be a lot of work to do to loop through the data and assemble it the way you’d like:

type: "POST",   
url: "/perc-metadata-services/metadata/get",   
contentType: "application/json; charset=utf-8",   
dataType: 'json',   
data: JSON.stringify({"criteria":["folder LIKE '/%'"],"maxResults":10,"orderBy":"dcterms:created desc, linktext\_lower asc"}),   
}); ```

k thanks!

My thought was to use this code to future proof my work. If I remove the tag/category part will this still work? That way I can just add the tag or category line back in after I’ve implemented tags or categories. Is this wise? or a waste of time?

I’m trying to do this same thing but for some reason it’s still not populating. Is this correct?


  

  

 
-    
  
 
  

  

  

 
-    
[Sample 1]("#")   
 
-    
[Sample 2]("#")   
 
  

  

or was I supposed to leave the " ?

Hi Andrew, I’m a fellow user and not Percussion support but that could be the source of your problem. [& quot;] is the hexadecimal code of a quote which don’t translate in code. Replace the [& quot;] with real [straight] quotes [like this "] and it could work!

oh I guess it automatically puts the " in where I had ". The top code should have the regular " in place of the " sorry about that!

Is there any way to pull in tags and categories associated with the pages appearing in this dynamically created auto list?

I have been doing more with content that is generated using the API. I would like to change the hyperlink URL that is being generated. Locally I can do this with document ready, but for some reason it’s not working with my dynamically generated content.

Any ideas as to how I could make this work, with a dynamically generated list?

I’m changing index to “pride-at-work-results”

$( document ).ready(function() {
// change the category hyperlink
$(’.perc-blog-list-category-container > a’).each(function(){
this.href = this.href.replace(‘index’, ‘pride-at-work-results’);
});
// end change the category hyperlink
});