Explore the community Forums Lectora Lectora Questions & Answers CurrentPageName and something clever

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #297486 Score: 0
    Profile photo of Trav Owers
    Trav Owers
    Member
    beginner
    intermediate
    friend finder
    advanced
    junior moderator
    contributor
    2 pts
    @towers9815

    So I want to trim the current page name and add it to varaible. (It’s best not ask why).

    On show for each page I want to add that pages name to varaible. I know we can do that with the inbuilt variable: CurrentPageName.

    Now here is the harder part, I only want the first part of the page name. (until the first space in the name).

    If I was using excel it would be =LEFT(A1,FIND(” “,A1)-1). Now i know that Lectora is not Excel ! but here are some examples:

    01 Welcome=01
    A1 The Cake=A1
    A2 the big Day=A2
    A3 The Welcome=A3
    B1 Finding your way=B1
    B2 Help=B2

    Well I hope that you get the idea.

    This is all for so that I can figure out what pages have been visited based upon the contents of the variable.

    So any way to do this ?

    Many thanks

    #297488 Score: 2
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    336 pts
    @ssneg

    1. Create a custom variable called _ShortPageName
    2. On title level, add the following actions:
    2.1. On Show > Modify Variable > _ShortPageName > Set to “CurrentPageName”
    2.2. On Show > Run JavaScript > this code:

    var pageName = VarCurrentPageName.getValue();
    var firstWord = pageName.split(” “)[0];
    Var_ShortPageName.set(firstWord);

    Voila, now the _ShortPageName contains the first word (before space) of your page name. Working demo attached.

    This post has received 2 votes up.
    • This reply was modified 4 years, 2 months ago by Profile photo of Daryl Fleary Daryl Fleary.
    Attachments:
    1. Title_201.zip
    #297521 Score: 0
    Profile photo of Trav Owers
    Trav Owers
    Member
    beginner
    intermediate
    friend finder
    advanced
    junior moderator
    contributor
    2 pts
    @towers9815

    Amazing stuff,

    I should have said I am doing this in Lectora Online so I cant open the AWT file. (Is there some way to convert it)

    I will place this Action in an Action Group and at the top of my course. The Action Group runs every page. This will save having to customise the action to write the first word of page name to a variable.

    I did attempt to create an action as above. But I was not able to get it working.

    In Debug the action and JS are being fired.

    Action [RunJS_On_CurrentPgeName->_ShortPageName on ActGrp] fired!

    But the variable: _ShortPageName remains empty ?

    #297531 Score: 0
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    336 pts
    @ssneg

    Please find the Lectora Online import package attached.

    Attachments:
    1. Title-20.pkg
    #297554 Score: 0
    Profile photo of Trav Owers
    Trav Owers
    Member
    beginner
    intermediate
    friend finder
    advanced
    junior moderator
    contributor
    2 pts
    @towers9815

    Fanstatic !

    Thanks for that I will take a look later today !

    #297557 Score: 0
    Profile photo of Trav Owers
    Trav Owers
    Member
    beginner
    intermediate
    friend finder
    advanced
    junior moderator
    contributor
    2 pts
    @towers9815

    Sorry mate I am getting the following message:

    The package file the you are trying to import was crate with a versio of the product that is not currently supported

    #297560 Score: 0
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    336 pts
    @ssneg

    Interesting. @support, @dfleary, why Lectora Online packages created in Lectora Publisher 12.1.1 can’t be imported into Lectora Online? (see above messages for the file).

    #297572 Score: 0
    Profile photo of Trivantis Support
    Trivantis Support
    Moderator
    friend finder
    intermediate
    advanced
    contributor
    junior moderator
    Trivantis Support
    verified member
    profile
    wise owl
    curious george
    19 pts
    @Support

    Titles created in Lectora v12 are not compatible with Lectora Online 2.0. The newer button, shape, and formatting features are not yet supported in Lectora Online. Our developers are working on bringing them back together for the next version.

    #297648 Score: 0
    Profile photo of Trav Owers
    Trav Owers
    Member
    beginner
    intermediate
    friend finder
    advanced
    junior moderator
    contributor
    2 pts
    @towers9815

    What a great shame that I cant even see the work that Sergey Snegirev has tried to share with me.

    Getting this working should be above adaptive display.

    #297821 Score: 1
    Profile photo of Daryl Fleary
    Daryl Fleary
    Member
    beginner
    intermediate
    advanced
    friend finder
    LUC16
    LUC16 Attendee
    contributor
    wise owl
    verified member
    17 pts
    @dfleary

    Trav:

     

    I’ve attached Sergey’s example as Lectora Online V2 compatible package file. You should be able to open this.

     

    Daryl

     

    This post has received 1 vote up.
    Attachments:
    1. Title-201.pkg
    #299046 Score: 0
    Profile photo of Trav Owers
    Trav Owers
    Member
    beginner
    intermediate
    friend finder
    advanced
    junior moderator
    contributor
    2 pts
    @towers9815

    This has been of great help. With a few modifications it has been a real time saver.

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.