roller-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guy Katz" <gk...@allot.com>
Subject RE: expose weblog uploaded files model?
Date Mon, 20 Aug 2007 16:55:02 GMT
Thanks for the help!;
It was fairly easy to write.
Here is the code if someone browses through the archives. It does
nothing special yet prints to console the uploaded resources if you use
{$files.filePrint} in your template. You can modify it however you like:

public class UploadedFilesModel implements Model {

    private static Log log =
LogFactory.getLog(UploadedFilesModel.class); 
    private WeblogPageRequest weblogPageRequest = null;
    
	public String getModelName() {
		return "files";
	}

	public void init(Map params) throws RollerException {
		this.weblogPageRequest =
(WeblogPageRequest)params.get("weblogRequest");	}

	public Object getFilePrint(){
		try {
			FileManager fileManager =
RollerFactory.getRoller().getFileManager();
			WebsiteData webSiteData =
weblogPageRequest.getWeblog();
			WeblogResource[] resources =
fileManager.getFiles(webSiteData,null);
			System.out.println("upload
files="+resources.length);
			for (WeblogResource resource : resources) {
	
System.out.println(resource.getName()+"-"+resource.getPath());
			}
		} catch (RollerException e) {
			log.warn("ERROR: FileManager failure", e);
		}
		return new Object();
		
	}
	
}

-----Original Message-----
From: Dave [mailto:snoopdave@gmail.com] 
Sent: Monday, August 20, 2007 6:13 PM
To: user@roller.apache.org
Subject: Re: expose weblog uploaded files model?

On 8/20/07, Guy Katz <gkatz@allot.com> wrote:
> How do I make the new model accessible (UploadedFilesModel)?
> Do I need to configure it somewhere?

The README.html explains that http://tinyurl.com/22r2to


>What does the getModelName method do?

That is the name by which you will refer to the model in templates. For
example:

   #set($myfiles = $mymodel.getMyFiles())

Where the model name is "mymodel"

- Dave

Mime
View raw message