Okay
  Public Ticket #919371
How to specify the variables in the shortcode?
Closed

Comments

  •  2
    atef_wagih started the conversation

    Hi,

    I am trying to use the %VAR1% in the shortcode. I searched the documentation and did not find any examples.

    I am building a mysql table that contain the Bible verses, and have a column for ID, column for Book, Column for Chapter and column for verse.

    When I want to show the verses of chapter 2 only, this sql works:

    SELECT wp_bible.id,
           wp_bible.book,
           wp_bible.chapter,
           wp_bible.verse,
           wp_bible.SVD
    FROM wp_bible
    WHERE wp_bible.chapter = %VAR1%

    when I specify the %VAR1% as 2 in the "placeholders" part in the backend.

    However, I can't find a way to specify the %VAR1% in the shortcode.

    what I am trying to achieve is to use one shortcode and change the chapter and book values of them.

    I don't want to create a separate table for each chapter. this will be a massive unnecessary work.

    Can you please help?

    thanks


  • [deleted] replied

    Hi atef_wagih,
    Thank you for your purchase.

    You can define var1 in shortcode like this:

    [ wpdatatable id=12 var1=150]

    You can take a look at this post from our documentation - Text - Video

  •  2
    atef_wagih replied

    Hi Milos,

    thanks a lot for the quick reply.

    I followed your instructions and was able to show only the verses from Chapter2. 

    However, when I tried to use %var2% to show only verse1 of chapter 2, it didn't work.

    it still shows all the verses of chapter 2.

    here is my sql:

    SELECT wp_bible.id,
           wp_bible.book,
           wp_bible.chapter,
           wp_bible.verse,
           wp_bible.SVD
    FROM wp_bible
    WHERE wp_bible.chapter >= %VAR1% AND wp_bible.verse >= %VAR2%

    here is the shortcode i used:

    [wpdatatable id=4 var1=2 var2=1]

    the result is here:

    https://coptic-treasures.com/wp/bible-trial-001/5/

    I have added 2 verses to chapter 2, so var=1 works, but var2=1 should show only verse 1, but the result is still showing the 2 verses.

    any clue why?

    thanks

  • [deleted] replied

    Hi atef_wagih,

    Is this الآية your verse column? If answer is yes the query is working fine because in WHERE clause you are using:

     WHERE wp_bible.chapter >= %VAR1% AND wp_bible.verse >= %VAR2%

    So it means

     WHERE wp_bible.chapter >= 2 AND wp_bible.verse >= 1

    And when you use >= (Grater then or equal) it will also select verse column where value is 1

    You can try to execute this query in phpmyadmin and see does it returns 1 or 2 rows:

    SELECT wp_bible.id,
           wp_bible.book,
           wp_bible.chapter,
           wp_bible.verse,
           wp_bible.SVD
    FROM wp_bible
    WHERE wp_bible.chapter >= 2 AND wp_bible.verse >= 1

  •  2
    atef_wagih replied

    Hi Milos,

    thanks a lot. you are right. I was just so excited about the "var" option as it will save me creating hundreds of tables.

    Much appreciated.

  • [deleted] replied

    Hi atef_wagih,

    You are welcome. We'd greatly appreciate it if you could take a minute and leave a review on CodeCanyon on this link. Thanks! 

  •  2
    atef_wagih replied

    Hi Milos.

    Thanks. I will do so straight way.

    I need to highlight to you that when I duplicated a table, the new table got the same css id, even though it has a new number and a new shortcode.

    I duplicated a table 3 times, then changed the css for one of them, but discovered that all of them saw the same changes. then I realised that all of them got thesame css id. you might want to look at this in future updates.


    Also, if you can please have a look at my other support ticket here: 

    https://tmsplugins.ticksy.com/ticket/919076/

    thanks a lot.

  • [deleted] replied

    Hi atef_wagih,

    I need to highlight to you that when I duplicated a table, the new table got the same css id, even though it has a new number and a new shortcode.
    - Can you please tell me on what CSS Id do you think?

    Also, if you can please have a look at my other support ticket
    - Another support agent will take a look at that issue because it is assigned to him.

  •  2
    atef_wagih replied

    Hi Milos.

    Here is the original table. It has ID=4

    https://coptic-treasures.com/wp/bible-trial-001/

    here are the duplicate tables:

    https://coptic-treasures.com/wp/bible-trial-001/2/
    https://coptic-treasures.com/wp/bible-trial-001/3/

    If you right clicked on the tables and inspected them, you will find that the 3 tables have:

    <table id="table_4" clas=bla bla bla..etc

    Now, one of the tables is LTR and the others are RTL. when I inspected the LTR one, I added the following css:

    #table_4 {
    direction: ltr !important;
    }

    So I found that the 3 tables changed to LTR.

    then I discovered that the 3 tables have the same id, so when I applied the css, all 3 changed direction.

    while in reality each table has its own shortcode with its own number.

    BTW, I left a good review. Thanks to your support.

    Cheers.

    Atef


  • [deleted] replied

    Hi atef_wagih,

    <table id="table_4" is not related with wpDataTable ID. That number is just showing number of tables on that page, but it should not be 4, it should be 1.

    Maybe before you had more tables on that page?

    If you want to apply CSS just for one table the bast way is to add CSS between <style></style> tags directly on page. Like that CSS will not affect on all tables that have same Class or ID.

    Thank you for great review

  •  2
    atef_wagih replied

    Hi Milos,

    sorry I don't understand the styling option you mentioned.

    can you please give an example?

    thanks

  • [deleted] replied

    Hi atef_wagih,

    If you want to apply CSS just for this table go to edit that page and in editor select Text

    Than you can add CSS between <style> tags and it will be applied just for that table. For example:


  •  2
    atef_wagih replied

    Hi Milos,

    thanks for the example. Actually this is very disappointing.

    First, because it is not the optimum way to add styling.

    second, on a large scale project like what I am planing for, it is very time consuming. this hinders the time save with the Vars.

    third, I have pasted one of the tables shortcode in a new post that did not have any tables before, and it gave id_2.

    so I will need to publish the page, then get the id then add the styling. then if anything happens and this id changed, then i will need to go back to the page and re-change the styling.

    is there any other way to give the table a class to control it?

    here is the trial post:

    https://coptic-treasures.com/wp/test-post-2/

    thanks

  • [deleted] replied

    Hi atef_wagih,

    so I will need to publish the page, then get the id then add the styling. then if anything happens and this id changed, then i will need to go back to the page and re-change the styling.
    If you have one table per page you can always use class .wpDataTables and add it between style tags.

    Unfortunately it is not possible to add class directly to table. You can add classes in optional column setup for each column separately. We will think about to add option in future for adding class to the table so it will be easier to control it.