Friday, April 21, 2017

Custom Rendering Variant Token Tool for SXA

Sitecore Experience Accelerator (SXA) provides a great way to alter how components render using a feature called Rendering Variant. The following post describes how I developed a new Rendering Variant tool that implements NVelocity templates. I found a way to extend a feature built into the great SXA.

For those that have not yet worked with NVelocity, it's essentially a mechanism for converting tokens into other text. This is often used in Sitecore standard values where you use $name to populate the title field.

UPDATE: SXA comes with some tools that you can take advantage of right now called $dateTool and $numberTool. Read more about them here and here.

Problem Statement

Marketing would like to have the page Url output in the website global search results.


As you can see above, the rendering shows a title, description, and url. Unfortunately  I was not able to figure out how to do this OOTB with SXA. Fortunately it took very little effort to write code for this.

Setup

There are a few steps you need to take in order for this to work.
  1. Have a need for it. Duh.
  2. Setup a Visual Studio project, something like Company.Foundation.Variants.
  3. Reference the SXA library Sitecore.XA.Foundation.Variants.Abstractions.dll, Sitecore.Kernel.dll, and Sitecore.NVelocity.dll.
  4. Add a new class to define the tool, such as Company.Foundation.Variants.NVelocityExtensions.LinkTool.
  5. Add a new class to register the tool, such as Company.Foundation.Variants.Pipelines.GetVelocityTemplateRenderers.AddTemplateRenderers.
  6. Patch the new pipeline in to getVelocityTemplateRenderers.
Here's a little snippet to get you started.

Usage

In the Rendering Variant configured for search results, add a VariantTemplate item. The template field should then contain something like the following:

<a href="$linkTool.GetItemLink($item)">$linkTool.GetItemLink($item,true)</a>

Here is the html set within the VariantTemplate.


That's pretty much all there is to setting it up. Hope you find this feature as helpful as I did!

18 comments:

  1. FOR IMMEDIATE ONLINE RELEASE - Today the Templar Fund, a publicly
    transparent Bitcoin Hedge Fund announced that after 272 days of continuous trading,
    they have achieved a compounded return on equity of 50.002% for its clients.

    Every $100 invested on November 21, 2018 is now worth $150.02.

    The Templar Fund is a privately-managed Bitcoin Hedge fund that publishes the
    entirety of its trade records for public consumption and audit, as well as comprehensive
    fund performance reports every 10 days.

    The Templar Fund welcomes clients from any jurisdiction, as it is not subject to FATCA
    or reporting requirements. To protect their anonymity & account security, clients only
    need to provide an e-mail address to create an account.

    For more information and to download the comprehensive report of the trade cycle
    detailed in this release visit: https://templar.fund/

    ReplyDelete
  2. WorldWide Mining Distributor CLOSING SALE! 50% OFF! Innosilicon G32 500, Obelisk SC1 Immersion, StrongU STU-U6, Antminer S17 Pro 53TH and much more!
    http://shopminersonline.com/

    ReplyDelete
  3. Next-Generation
    Cryptocurrency Exchange
    Buy, Sell, and Spend at https://www.coinzoom.com/
    Join telegram : https://t.me/coinzoomcommunity
    Twitter : https://twitter.com/GetCoinZoom
    Get Early Access: https://www.coinzoom.com/early-access/

    #crypto #ico #bitcoin #btc #investment #makemoney #coin

    ReplyDelete
  4. Fast crypto to crypto, wallet to wallet, non custodial swap exhange service, with a unique "social good" business model.
    Try us today at : https://changeangel.io/

    #crypto #ico #bitcoin #btc #investment #makemoney #coin

    ReplyDelete
  5. Fast crypto to crypto, wallet to wallet, non custodial swap exhange service, with a unique "social good" business model.
    Try us today at : https://changeangel.io/

    #crypto #ico #bitcoin #btc #investment #makemoney #coin

    ReplyDelete
  6. Coenx is a hybrid #Advertising and Reward platform with a discounted #Crypto #Exchange at a lowest fee of 0.03 percent. Join Coenx to View ads and Earn #Crypto.
    https://www.coenx.com/

    And Earn Crypto in 1 2 3 Steps..
    at : https://bitcoin.dotcompal.co/Coenx-AB

    ReplyDelete
  7. Fydcoin is a cryptocurrency for the gig economy. With staking and masternodes and a decentralized marketplace for freelancers.
    Website: https://fydcoin.com
    Facebook: https://m.facebook.com/FYDcoin

    ReplyDelete
  8. Goldenugget is the combination of #decentralized #blockchain technology and the most antique, reliable, value increasing and stable asset: GOLD! BUY TOKENS now at : https://www.goldenugget.ch/

    ReplyDelete
  9. Cloud token is a super wallet that contains all the top coins like bitcoin and etc.... they partner with a company called Jarvis that trade all your crypto coins for you and give you anywhere from 8% to 12 % a month on your investment
    https://cloudtokensystem.com/?aff=Gregjerome148

    ReplyDelete
  10. Sign up now for 1,000 FREE credits! Dont forget to check out the awesome affiliate program!
    https://onecryptocasino.com?ref=2

    ReplyDelete
  11. SRM Token is a cryptocurrency mining with lifelong free electricity, based on an innovative waste-processing plant with a 100% recycling capacity. SolarMining offers the opportunity for investors to be a share holder of a large-scale mining operation without the need to buy and configure expensive mining equipment. SolarMiningPower believes in green energy. Everything will be done for environmentally friendly and safe mining. We can make huge benefit and still take care of our beautiful planet.
    https://solarminingpower.com/whitepaper.pdf
    https://www.solarminingpower.com/
    https://bitcointalk.org/index.php?topic=5197760.new#new

    Solarmining offers an exceptional reward to all ICO participants.
    www.solarminingpower.com
    If you buy 100 coins for 15 dollars, ether addresses will be drawn and will receive a bonus equivalent to :
    1000 ether for the 1st winner
    350 ether for the 2nd winner
    170 ether for the 3rd winner
    120 ether for the 4th winner
    70 ether for the 5th winner
    Contact us by email contact@solarminingpower.com and follow the draw by subscribing to our
    Telegram channel t.me/solarminingpowerchile
    and twitter https://twitter.com/mining_solar
    https://www.youtube.com/watch?v=H3F83VhZcWs

    ReplyDelete
  12. Manufacturing Execution System (MES), manufacturing automation systems and optimization of manufacturing activities initiate, monitor, optimize, and documents manufacturing processes from the eginning of the assignment to the manufacturing of end products in real-time.

    Performance analysis (statistical and mathematical analysis, monitoring process performance, calculation of TEC, calculation of operation time and equipment downtime, generation of reports);
    • Programming of manufacturing schedules;
    • Controls of documents (electronic document circulation);
    • Human resource management (employee management);
    • Coordination of technological processes and end product tracking.
    Read more on website meschain.io

    Coin Information:
    Coin Name: MES
    Coin Type: ERC20 - Ethereum
    Total Supply: 7,000,000,000 MES
    Total Circulation: 1,000,000,000 MES

    MesChain is currently listed on the Vindax and Cointiger exchanges. Users wishing to purchase MesChain must open an account on the Cointiger exchainge website.

    https://www.cointiger.com/en-us/#/trade_center?coin=mes_eth

    The details of the ICO are as follows:

    Sale Start Date: 22/09/2019 00:00 (GMT+3)
    Sale Finish Date: 04/10/2019 24:00 (GMT+3)
    Sale Price: 70 Gwei
    Total Sale: 631,400,000 MES

    MesChain is a registered company
    Company Registration number: KZ07UWQ01487171
    Email: info@meschain.io

    Website: https://meschain.io/
    Facebook: https://web.facebook.com/MesChainproject?_rdc=1&_rdr
    Vk: http://vk.com/meschain
    Twitter: https://twitter.com/MeschainMES
    Instagram: https://www.instagram.com/meschainmes/
    Reddit: https://reddit.com/user/MesChain
    Telegram: https://t.me/MesChain_English
    Medium — https://medium.com/@PERHALIC

    ReplyDelete
  13. The most ambitious application of blockchain technology to the transportation, security, and avaiation sectors, starting first with ride-hailing services. In essence, RideNodes™️ are a virtual currency and smart contract apparatus that aims to realign the interests of Drivers, Riders, & Service Coordinators (collectively referred to as our network participants) who already utilize ride-hailing services (such as Uber, Lyft, Via, and even traditional taxi & limousine companies), by providing a superior platform not limited to logistics, payments, credential verification, incident responses, and a special emphasis on safety and security for BOTH the riders and drivers.

    --- ICO ---
    The initial ICO ran from Aug 20, 2019 to Oct 29, 2019. The marketing campaign was not started until 10/16/2019 - as a result, there were no significant sales during the two week period. The ICO was transferred to a new contract as an extension to the initial ICO through Jan 8, 2020.

    ICO Details
    Token: RIDE
    Tokens on sale (40% of Total Supply): 10,000,000,000
    Type: ERC20
    Price: 1 ETH = 4000 RIDEs
    Soft Cap: 25,000 ETH
    Hard Cap: 2,500,000 ETH
    Accepted currencies: ETH (only)
    ICO Period: Aug 20, 2019 to Jan 8, 2020 (extended from Oct 29, 2019)

    --- IEO ---
    Currently, we are working with p2pb2b.io to start an IEO in a about a week. Please see the attached and try to satisfy the recommendation by p2pb2b.io as shown in the attached document IEO Marketing Manual.

    IEO Details
    Token: RIDE
    Tokens on sale (40% of Total Supply): 10,000,000,000
    Type: ERC20
    Price: 1 RIDE = $0.05 USD
    Soft Cap: $5,000,000
    Hard Cap: $500,000,000
    Accepted currencies: USD/UDT/ETH/BTC
    IEO Period: TBD

    Differences between ICO and IEO
    Soft Cap & Hard Cap
    Accepted currencies

    Website is http://www.ridenode.io
    Whitepaper

    ReplyDelete
  14. "The Money Project" by OkGlobal Coin & SWITCH is the first registered, regulated and compliant blockchain project of its kind. We are the first and only project that is aimed at the complete takeover of banking, finance, exchange and payment processing via a living reactive decentralized autonomous organization, DAO. A living DAO that operates globally aimed to replace faith based problematic fiat currency and bring back the use of "money" that will rise in value to beat inflation rates and can be used globally without threat of loss, theft or unfair confiscation.

    Okglobal Coin security token offering and initial exchange offering launched! Available directly from our website or at LAtoken exchange. More exchanges to come!! https://exchange.latoken.com/ieo/OKGS?_ga=2.113327559.159130170.1573647574-1345690785.1569984803

    website:
    https://www.okglobalcoin.com/
    https://okglobalcoinsg.com/

    ReplyDelete
  15. Decentralized Exchange with super low fee: Maker 0.025% and Taker 0.075%
    The Community Stakes Decentralized Exchange, or CSDEX is available now to serve the crypto community. If you are crypto traders, CSDEX brings you a more convenient experience in buying and selling ERC20 tokens. like other Decentralized Exchanges, no registration is required. In addition, CSDEX offers a super low fee: only 0.025% for makers and 0.075% for takers.
    There is also a starting video that may help: https://youtu.be/0xdRb3PCY_g
    If you are ICO/IEO/ERC20 token owner and looking for simple and transparent way to list your token, CSDEX is your choice.
    CSDEX official website is https://csdex.site or enter you could directly trade at https://trade.csdex.site

    ReplyDelete
  16. http://blockchain.cam/ is available on Sedo.com !!
    Make your statement on the web with the exclusive Blockchain name solely in the URL!
    That's http://blockchain.cam/

    The video is also here: https://www.youtube.com/watch?v=Pgl0N2rpoXw

    ReplyDelete
  17. Win up to 25 Free Bither Tokens every two hours. Bither Airdrop/Spin-the-Wheel/Faucet. 25% Referral commissions. 100 Bither = 1 ETH. To get started Sign-Up/Register Here: https://panel.bither.one/?ref=Bitherian99186 Bither: New Eco-Friendly and Layered Decentralized Economy Three-layer solution Multi-mining capability Optimizing energy consumption https://panel.bither.one/?ref=Bitherian99186

    ReplyDelete
  18. #LocalBitcoins Auto #Bot gives you the chance to boost your Localbitcoins earnings and increase #trading volumes by using smart algorithms.
    https://localautobot.com/

    ReplyDelete