Quantcast
Channel: XWiki Forum - Latest topics
Viewing all articles
Browse latest Browse all 1219

Need help for custom buttons in XWiki

$
0
0

Hello everyone,

We want to create our own button in XWiki, which includes a link when the button is clicked, the button text and also the alignment of the button. For this we have the following velocity-code.

{{velocity}}
#set($buttonLink = $wikimacro.parameters.buttonLink)
#set($buttonText = $wikimacro.parameters.buttonText)
#set($buttonIcon = $wikimacro.parameters.buttonIcon)
#set($buttonAusrichtung = $wikimacro.parameters.buttonAusrichtung)

#if ("$!buttonLink" == '')
  #if ($hasEdit)
  #end
#else
  #set($discard = $xwiki.ssx.use('XWiki.Code.LRA-OA.Makros.Button.WebHome'))
  #if($buttonLink.toLowerCase().startsWith('www.'))
    #set($buttonLink = "https://${buttonLink}")
  #end
  #if($buttonLink.toLowerCase().startsWith('http') && !$buttonLink.toLowerCase().contains('.int'))
    #set($target = '_blank')
    #set($href = $buttonLink)
  #else
    #set($target = '_self')
    #set($href = $buttonLink)
  #end 

  #if("$!buttonAusrichtung" == 'rechts')
    #set($alignmentClass = "button-container-right")
  #elseif("$!buttonAusrichtung" == 'mittig')
    #set($alignmentClass = "button-container-center")
  #else
    #set($alignmentClass = "button-container-left")
  #end
  
{{html wiki="false"}}
  <div class="${alignmentClass}">
    <a class="lraoa-button" href="${href}" target="${target}">
      <span class="buttonFont">&nbsp;&nbsp;${buttonText}</span>
    </a>
  </div>
{{/html}}
#end
{{/velocity}}

So far it works quite well, but we always have an empty line in front of the button. We have already looked at CSS, but have not found a solution. Thanks for a quick tip!

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1219

Trending Articles