Re: [xwiki-users] Printing sections

2008-02-22 Thread Jerome Velociter
Hi Vito,

The best place to contribute this macro is http://code.xwiki.org.
Just click the "add" button under Latest macros, fill the form, and you
will be done.

Thank you,
Jerome.

> Hi all,
>
> I've written a macro that allows to print just one section from an
> xwiki-page.
> I don't know if someone could find it useful, anyway, here it is.
>
> ---
> #macro(allowPrintSection)
>
> 
>   
>   
> #set ($i = 0)
> #set ($tocData = ${doc.getTOC(2, 2, false)})
> #foreach ($tocEntry in $tocData.entrySet())
>   #set ($i = $i+1)
>value="$i">$xwiki.parseContent($tocEntry.value.text)
> #end
>   
>   
> 
>
> #if($request.printSection)
>   #set ($sections = $doc.getContent())
>   #set ($i = 0)
>   #foreach ($section in $sections.split("
> 1.1 "))
> #if ($i == $xwiki.parseInt($request.printSection))
>   #set ($newContent = $section)
> #end
> #set ($i = $i+1)
>   #end
>   #set ($newContent = "1.1 "+$newContent)
>   #set ($newDoc = $xwiki.getDocument("Main.PRINT_tmpSectionToPrint"))
>   #if ($newDoc == $xwiki.getNull())
> #if (!$xwiki.copyDocument($request.pageName,
> "Main.PRINT_tmpSectionToPrint"))
>   *Error while printing section...*
> #end
>   #end
>   $newDoc.setContent($newContent)
>   $newDoc.save()
>   Section ready to be printed: click here.
> #end
> #end
>
>
> Any ideas or suggestions are welcome!
> Vito
>
> --
> Vitantonio Messa
> +358 46 889 48 49 - [EMAIL PROTECTED]
> COSS - The Finnish Centre for Open Source Solutions
> @ Technology Centre Hermia Ltd.
> Hermiankatu 1, FIN-33720 Tampere, FINLAND
>
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>


___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Printing sections

2008-02-22 Thread Vitantonio Messa
Thanks for the tip: I'll do that.

Guillaume Lerouge wrote:
> Hi Vitantonio,
>
> thanks for this snippet :-)
>
> It would be even better if you could post it on code.xwiki.org 
> , in the code Snippet section.
>
> Thanks in advance,
>
> Guillaume
>
> On 22/02/2008, *Vitantonio Messa* <[EMAIL PROTECTED] 
> > wrote:
>
> Hi all,
>
> I've written a macro that allows to print just one section from an
> xwiki-page.
> I don't know if someone could find it useful, anyway, here it is.
>
> ---
> #macro(allowPrintSection)
>
> 
>   
>   
> #set ($i = 0)
> #set ($tocData = ${doc.getTOC(2, 2, false)})
> #foreach ($tocEntry in $tocData.entrySet())
>   #set ($i = $i+1)
>value="$i">$xwiki.parseContent($tocEntry.value.text)
> #end
>   
>value="Print
> section"/>
> 
>
> #if($request.printSection)
>   #set ($sections = $doc.getContent())
>   #set ($i = 0)
>   #foreach ($section in $sections.split("
> 1.1 "))
> #if ($i == $xwiki.parseInt($request.printSection))
>   #set ($newContent = $section)
> #end
> #set ($i = $i+1)
>   #end
>   #set ($newContent = "1.1 "+$newContent)
>   #set ($newDoc = $xwiki.getDocument("Main.PRINT_tmpSectionToPrint"))
>   #if ($newDoc == $xwiki.getNull())
> #if (!$xwiki.copyDocument($request.pageName,
> "Main.PRINT_tmpSectionToPrint"))
>   *Error while printing section...*
> #end
>   #end
>   $newDoc.setContent($newContent)
>   $newDoc.save()
>   Section ready to be printed: click here.
> #end
> #end
>
>
> Any ideas or suggestions are welcome!
> Vito
>
> --
> Vitantonio Messa
> +358 46 889 48 49 - [EMAIL PROTECTED]
> 
> COSS - The Finnish Centre for Open Source Solutions
> @ Technology Centre Hermia Ltd.
> Hermiankatu 1, FIN-33720 Tampere, FINLAND
>
> ___
> users mailing list
> users@xwiki.org 
> http://lists.xwiki.org/mailman/listinfo/users
>
>
>
>
> -- 
> http://wikibc.blogspot.com/
> 
>
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>   

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Printing sections

2008-02-22 Thread Guillaume Lerouge
Hi Vitantonio,
thanks for this snippet :-)

It would be even better if you could post it on code.xwiki.org, in the code
Snippet section.

Thanks in advance,

Guillaume

On 22/02/2008, Vitantonio Messa <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I've written a macro that allows to print just one section from an
> xwiki-page.
> I don't know if someone could find it useful, anyway, here it is.
>
> ---
> #macro(allowPrintSection)
>
> 
>   
>   
> #set ($i = 0)
> #set ($tocData = ${doc.getTOC(2, 2, false)})
> #foreach ($tocEntry in $tocData.entrySet())
>   #set ($i = $i+1)
>value="$i">$xwiki.parseContent($tocEntry.value.text)
> #end
>   
>   
> 
>
> #if($request.printSection)
>   #set ($sections = $doc.getContent())
>   #set ($i = 0)
>   #foreach ($section in $sections.split("
> 1.1 "))
> #if ($i == $xwiki.parseInt($request.printSection))
>   #set ($newContent = $section)
> #end
> #set ($i = $i+1)
>   #end
>   #set ($newContent = "1.1 "+$newContent)
>   #set ($newDoc = $xwiki.getDocument("Main.PRINT_tmpSectionToPrint"))
>   #if ($newDoc == $xwiki.getNull())
> #if (!$xwiki.copyDocument($request.pageName,
> "Main.PRINT_tmpSectionToPrint"))
>   *Error while printing section...*
> #end
>   #end
>   $newDoc.setContent($newContent)
>   $newDoc.save()
>   Section ready to be printed: click here.
> #end
> #end
>
>
> Any ideas or suggestions are welcome!
> Vito
>
> --
> Vitantonio Messa
> +358 46 889 48 49 - [EMAIL PROTECTED]
> COSS - The Finnish Centre for Open Source Solutions
> @ Technology Centre Hermia Ltd.
> Hermiankatu 1, FIN-33720 Tampere, FINLAND
>
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>



-- 
http://wikibc.blogspot.com/
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Printing sections

2008-02-22 Thread Vitantonio Messa
Hi all,

I've written a macro that allows to print just one section from an 
xwiki-page.
I don't know if someone could find it useful, anyway, here it is.

---
#macro(allowPrintSection)


  
  
#set ($i = 0)
#set ($tocData = ${doc.getTOC(2, 2, false)})
#foreach ($tocEntry in $tocData.entrySet())
  #set ($i = $i+1)
  $xwiki.parseContent($tocEntry.value.text)
#end
  
  


#if($request.printSection)
  #set ($sections = $doc.getContent())
  #set ($i = 0)
  #foreach ($section in $sections.split("
1.1 "))
#if ($i == $xwiki.parseInt($request.printSection))
  #set ($newContent = $section)
#end
#set ($i = $i+1)
  #end
  #set ($newContent = "1.1 "+$newContent)
  #set ($newDoc = $xwiki.getDocument("Main.PRINT_tmpSectionToPrint"))
  #if ($newDoc == $xwiki.getNull())
#if (!$xwiki.copyDocument($request.pageName, 
"Main.PRINT_tmpSectionToPrint")) 
  *Error while printing section...*
#end
  #end
  $newDoc.setContent($newContent)
  $newDoc.save()
  Section ready to be printed: click here.
#end
#end


Any ideas or suggestions are welcome!
Vito

-- 
Vitantonio Messa
+358 46 889 48 49 - [EMAIL PROTECTED]
COSS - The Finnish Centre for Open Source Solutions
@ Technology Centre Hermia Ltd.
Hermiankatu 1, FIN-33720 Tampere, FINLAND

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users