We will be introducing some exciting new additions to the default template for the default delegation page, making it even more customisable. We’re currently testing, committing, and preparing these changes for release.
If you prefer to create your own custom page, you can do so by extracting all the parts of the template and adding them into your page builder as short codes. Below is a comprehensive list of all the short codes you’ll need, along with their corresponding original template part calls for the delegation page.
Template Layout Parts & Corresponding Shortcodes #
For all customised layouts, you will require the overarching code required for the delegation page. This pulls in variables, such as the stake pool ID from the configuration.
[cardanopress_component_pooldelegation]
Delegation page wrapper short coded. Required for loading all the required page variables and code. You must have this as short code if you’re creating your own custom delegation page in a page builder such as WPBakery, Elementor or Divi.
Delegation Details #
This displays the details of the stake pool that you are delegating to from what is registered on chain via Blockfrost. This is to help confirm the pool that you are delegating too. If this data doesn’t appear, then you may have missed something in your CardanoPress configuration or Blockfrost API key setup. Ensure you have cache disabled for the page to avoid any issues.
PHP
<?php cardanoPress()->template('part/delegation-details'); ?>
Short code
[cardanopress_template name="part/delegation-details"]
Delegation Connect Button #
If your site doesn’t have a connect button in the header nav area of the website, this will allow a user to connect their wallet in order to start the delegation process. You can remove this button but as a step by step process for users, its easier to have the prompt on screen to walk them through delegation.
PHP
<?php cardanoPress()->template('part/delegation-connect'); ?>
Short code
[cardanopress_template name="part/delegation-connect"]
Delegation Button #
This code loads the delegation button. The button write the required transaction, registers a wallet for delegation if it isn’t and then prompts the wallet to delegate. This is a required button to allow for user delegation.
PHP
<?php cardanoPress()->template('part/delegation-process'); ?>
Short code
[cardanopress_template name="part/delegation-process"]
Delegation Results #
This code snippet shows the delegation results from the user. It will show the transaction hash as soon as the wallet has delegated. It may take a few moments for the wallet submit the transaction to the blockchain and allow for viewing on a block explorer. This code snippet isn’t essential, but is nice to have as it gives the user a good confirmation that the transaction has been successful.
PHP
<?php cardanoPress()->template('part/delegation-result'); ?>
Short code
[cardanopress_template name="part/delegation-result"]
Closing Delegation Tag #
The final short code that you will need on the page is the closing tag for the page. This is a required short code to close the area for the delegation code.
Short code
[/cardanopress_component_pooldelegation]
Overriding the Template in Your Own Theme #
If you are wanting to override the entire page at a code level, you can do so by copying the template itself into your child theme and overriding the layout.
yourtheme/cardanopress/pool-delegation.php
The file that you will need to copy to your theme can be found here:
https://github.com/CardanoPress/cardanopress/blob/main/templates/pool-delegation.php