+ Reply to Thread
Page 1 of 4 123 ... LastLast
Results 1 to 10 of 38

Thread: Trying to add the following php script...

  1. #1

    Trying to add the following php script...

    Hello,

    I am trying to add the following php script which is just for my header, to display a random image. I have tested this script outside of the Flynax template folder and I can confirm it works, but when I put the code into the header.tpl file I don't get any error, but no images displayed either


    PHP Code:
    Only registered members can view the code
    I have tried creating my 'images' folder in the {$rlTplBase} folder which is the general_wide root with no luck and also tried creating the 'images' folder in the same folder as the header.tpl and updated the path in the script with no luck either. I hope someone can figure this out, as I have searched the web night and day to get this script. Now I need to get it working within the Flynax header.tpl (template)...Please help, I am sure it's something simple, but I am exhausted.

    Thank you in advance!
    Brian

  2. #2
    Hello Brian,

    Will be better and cleaner to put this code in php file and then register new variable or array to smarty.
    For example add your php code to: ftp://includes>>controllers>>common.inc.php
    and instead last line:

    PHP Code:
    Only registered members can view the code
    add new code:

    PHP Code:
    Only registered members can view the code
    Then in your header.tpl file use this variable: {$random_image}
    I think it should help to you.
    Viktor,
    Flynax technical department,
    Best wishes.

  3. #3
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    2,110
    Hello,

    In php code you can't use smarty variables like you do in smarty

    it should be like this:
    PHP Code:
    Only registered members can view the code
    but better use directly php constant RL_TPL_BASE
    and concatenate variables with text via dot '.' like:

    PHP Code:
    Only registered members can view the code
    Last edited by Rudi; April 19, 2018 at 09:33 AM.

  4. #4
    In the Smarty already registered from php variable {$rlTplBase}
    And we are using smarty for separating php code and html code. That's why I suggest using php code in php files and html code with smarty in tpl files.
    Please don't use php and html together in the same files.
    Viktor,
    Flynax technical department,
    Best wishes.

  5. #5
    For some reason, I am getting
    PHP Code:
    Only registered members can view the code
    I have added the following php code to the bottom of the includes/controllers/common.inc.php file: (NOTE: I HAD TO SNIP SOME OF THE CODE DUE TO THE LENGTH, BUT IT'S THE SAME AS IN MY PREVIOUS POST)

    PHP Code:
    Only registered members can view the code
    Snip..


    PHP Code:
    Only registered members can view the code
    Then in my header.tpl I added:
    PHP Code:
    Only registered members can view the code
    Please help me!
    Thank you
    Brian
    Last edited by Brian Jester; April 23, 2018 at 01:09 AM.

  6. #6
    Hello Brian,

    I have found php error in your code.
    Try to use my code:

    PHP Code:
    Only registered members can view the code
    Let me know about results.
    Viktor,
    Flynax technical department,
    Best wishes.

  7. #7
    yes, that did it, thank you!

    Soon you should make video tutorials and put them on the forum to view or download for off line viewing so users can follow how to work better with the smarty template and flynax system. I know it is easy for some of you guys, but offering those tutorials would be awesome to everyone who is trying to get a grasp on this stuff, it's hard enough to manage the website, this makes it really time consuming to get things done! Because once we see code as in this example, some code may have worked in previous versions of flynax, and not in this version of flynax...But your code Viktor, did in fact work, which I thank you for!

    Thanks again!
    Brian

  8. #8
    Ok, we will discuss your proposal with our co-workers.

    Quote Originally Posted by Brian Jester
    But your code Viktor, did in fact work, which I thank you for!
    Glad to hear it Have a nice day.
    Viktor,
    Flynax technical department,
    Best wishes.

  9. #9
    Quote Originally Posted by Viktor View Post
    Ok, we will discuss your proposal with our co-workers.


    Glad to hear it Have a nice day.
    But, hold on, I would still like to discuss this a bit more...

    Ok, I would like to ask based on your knowledge (your honest opinion), if you think it would be better to store the images (as links) and the links for each image in the database, or do you think this code as it currently stands (with the array, and no db connection) would have any drawbacks from the website users' perspective or no?

    Thank you
    Brian

  10. #10
    Hello Brian,

    Nope doesn't matter. Because you are using 100-200 images only and your code is ok. Don't worry and use it
    Viktor,
    Flynax technical department,
    Best wishes.

+ Reply to Thread