How to create a custom page counter in Lectora?

Knowing how to create a custom page counter can help you with those tricky titles where you don’t want to include the introduction pages and the menu page etc. in your page count or maybe you have your title sorted in multiple chapters and you want the page counter to include all of the pages that are in the different sections but exclude that starting pages. The simple page counter doesn’t offer you the ability to exclude the first few pages of the title from the page count but the custom page counter will let you do just that.

Step by Step instructions

1. First of all we will need 3 variables. You can create them by clicking the Variables button in the Manage section under the Tools tab.

Custom Page Counter1

2. A window will apear where you will need to click the Add button at the bottom left of the screen.

Custom Page Counter2

3. Clicking the add button will create a new variable. We will use this variable to store the total number of pages that we want to apear in the page counter. Change the name of the variable to something that makes sense to you and that is easy to remember (i will call it RealPageCount). Leave the Initial value 0. Click OK. Repeat this process and create another variable that we will use to save the number of the current page (i will call it RunningPageCount). Create a third variable that we will actualy use to store our custom page counter in (i will call ir CustomPageCounter) but this time leave the Initial value field empty.


4. After you have created the variables we can start building the page counter. Create a group that we will use to group the actions that will create out page counter. You can do that by clicking the Group button in the Add More section under the Insert tab and that will create a new group in yor Title Explorer. After it has been created you can rename it to whatever you want.


5. We will start by adding an action that will insert the beginning of the page counter which in my case will be the word “Page ”. I recomend that you rename the actions to something that is more readable and better explains the action so that if you would return to the title after a while you would more easily know what they do. You can add an action by right-clicking on the group that we just created and clicking Add Action. That will open the Action tab at the top where you will select the “Modify Variable“ option from the dropdown in the Action and Target section. In the target dropdown find the variable that you created for storing the custom page counter. In the Type dropdown select the “Set Equal To“ option and in the Value field you can write what you want the custom page counter to begin with. So the CustomPageCounter currenty contains just the word “Page “ and a space after it. But you will see how we will build on to it to make it what we want.


6. Create a new action that will modify the variable that we created to hold the total amount of pages we want to show in the page counter. Set the variable to be equal to the variable PagesInTitle. This is an inner variable of Lectora that holds the total number of pages that are in a title. You can do that by writing VAR(PagesInTitle) or choosing the variable from a dropdown in the bottom of the window.


7. Create another action that modifly a variable. But this time set the variable that we created to hold the number of the current page to equal the variable PageInTitle. This is another inner variable of Lectora that contains the number of the page that you are currently viewing.


8. This is where the magic happens! Create an action that modifys a variable but this time select “Subtract from Variable” in the type dropdown. Select RealPageCount In the Value field write the number of pages you want to exclude from the page counter. In my case it’s 3 but you can just put in your own number. Do the exact same thing for the RunningPageCount aswell.

CustomPageCounter8     CustomPageCounter9

9. Now we can just add the pieces of our custom page counter together. Create an action that modifys the variable CustomPageCounter by adding the contents of RunningPageCount at the end of it. Do that again just this time add a seperator “ of ” at the end of the CustomPageCounter. And to finish it off create another action that adds the contents of the variable “RealPageCount” at the end of CustomPageCounter. So now the variable CustomPageCounter contains: “Page VAR(RunningPageCount of VAR(RealPageCount)”.

CustomPageCounter10     CustomPageCounter11      CustomPageCounter12

10. This page counter works by replacing an existing text blocks contents with the contents of the variable CustomPageCounter. So we need to create a text block that we will insert our page counter into. You can create a text block by going into the Insert tab and clicking on Text Block button in the Add Text section. Name the text block whatever you want. I named mine Page Counter.


11. Now we need to create an action that will actualy replace the content on the text block with the custom page counter. Create a new action and select Change Contents in the action dropdown. Select Page Counter text block as the target and CustomPageCounter as the value.


12. Now create an action outside of the group that we created. Select Show as the trigger for the action and the Run Action Group as it’s action. The target should be the group of actions that we created previously. In my case it’s called change_counter_group_DO_NOT_EDIT. This action will run the group of actionts that create our custom page counter in every page that it shows up on and that has the textfield Page Counter in.


This is how the final page counter looks like. And as you can see it shows that it’s the 1st page although it is actualy the 4th page of the title and the full count of pages excludes the first 3 pages.


I must add that the Page Counter text block must be the exact same text block on every page you want the page counter to show up on. It cannot be a copy of the original field. You will have to use the inheritance settings to show it on those pages you want it to show up on and hide it on those you don’t want it to show up on. You can also modify the actions to make it do alot more.

Explore all Lectora templates

Get our templates and start learning by doing! Get access to hundreds of interactions built in Lectora that you can use in your courses or use them as a learning material! Explore hundreds of course starters, games, click & reveal, info pages and other test templates. Click the button below and see all of our Lectora templates!



Leave a Reply

Your email address will not be published.