Include in the page

Discussion in 'General Help' started by autosurf, Nov 25, 2019.

  1. autosurf
    • Licensed

    autosurf Member

    Hi,

    I would like to change my version of VL but for the moment, I use during my creation of pages, the possibility to add a PHP treatment in my pages with the function include.
    To be done on my page, I have the code: {include "https://www.classement.com/test.php"} for example in which I have a PHP treatment on my test page. This allows me to get a dynamic page and that corresponds to my needs.
    example of page: https://www.classement.pro/prochains-supprimes/

    I tested the new version of VL and it does not interpret the accolages: /

    Is there a possibility to activate this or fix this in the new version of VL?

    Thank you in advance for your assistance
  2. Basti
    • Staff

    Basti Administrator Staff Member

    hmm that functionality hasnt changed since its creation.

    Does your error log gives any hint?
  3. autosurf
    • Licensed

    autosurf Member

    Hi,

    in the file sources/misc/skin.php (VL 1.6) , i have so
    and for this function, i have (0.9)
    With this last code (0.9), the {include} is OK when i include this in my page

    i just read "create_function" is "Warning This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged."

    would it be possible to have a function compatible with the current versions of PHP that works with the include in a personal page?

    Thank
  4. Mark
    • Staff

    Mark Administrator Staff Member

    I just tested on PHP 7.2 and 7.3 in both cases the {include "https://mydomain/testscript.php"} worked as expected. Can you check your error_log for more details?

    Edit: there is no "create_function" in 1.6, we are already 7.2+ ready
  5. autosurf
    • Licensed

    autosurf Member

    I don't have any error, i have just in my test page : {include "https://mydomain/testscript.php"}

    it's just that it does not interpret the inclusion command but displays it as if it were text to display

    And i have try with php 7.1.33 and php 7.2.24 the result is the same
  6. Mark
    • Staff

    Mark Administrator Staff Member

    What template did you paste the tag into?
  7. autosurf
    • Licensed

    autosurf Member

    I try with parabola (defaut) and with other, the problem is the same.

    When i put my include in : /index.php?a=admin&b=edit_page&id=test
    with the V0.9, it's interpretate and i can see the generate page
    with the V1.6, it's only text => {include "https://mydomain/testscript.php"}
  8. Mark
    • Staff

    Mark Administrator Staff Member

    Those tags only work in the skin templates, not inside the content of custom pages.

    I'll see if we can make that work for you.
  9. autosurf
    • Licensed

    autosurf Member

    thank you mark, in fact my problem comes only custom pages from the beginning, sorry not to have been precise enough in my request.

    It works well with version 0.9 however, as stated in the message above.
    and if I replace the function parse ($ skin) of the V1.6 by the function parse ($ skin) of the V0.9, the include works well on the pages custom but the function create_function is depreciated with php 7: /

    I hope you'll find a solution, this ability to include is very convenient for custom pages, it can make them dynamic (for example, including php or readings in the database)
  10. Basti
    • Staff

    Basti Administrator Staff Member

    Do not edit skin.php or any core file. This is quite easy to integrate into the page.php file using a similar function
    Ill post a updated page.php in a few minutes, though untested, cause lack of time
  11. Basti
    • Staff

    Basti Administrator Staff Member

    make a backup of sources/page.php

    This is for VL 1.6
    in that file find the following

    Code:
        $TMPL['meta_description'] = !empty($description) ? $description : $TMPL['meta_description'];
    
    Right above on a new line, add the following code
    Code:
        // Include tag
        $TMPL['content'] = preg_replace_callback('/{include \"(.+?)\"}/i', function($matches) {
           
            return file_get_contents($matches[1]);
        }, $TMPL['content']);
    Mark and autosurf like this.
  12. autosurf
    • Licensed

    autosurf Member

    The solution that Basti proposed works very well. You are Great

    Thank you Basti and Mark for your research and your work !
  13. Mark
    • Staff

    Mark Administrator Staff Member

    Nice, we should probably roll this into 1.7?
    autosurf likes this.
  14. Basti
    • Staff

    Basti Administrator Staff Member

Share This Page