Before you ask please READ THIS

randomly select short code (rife pro / elementor)

in Rife Posts: 248
Hi Air

Already came up with a new question (so you don't get bored ;))
For an upcoming website my clients will need a video clip (automatically) starting using the image from frame 1 as poster image and after the clip has finished playing the video should "freeze" with the last image of the clip.
With the help of support from slider Revolution this is not much of a problem... the actual problem starts now:

Each page hast a clip that should randomly be selected when chaning pages (or reload page). Now the Revo slider is placed in elementor/rife pro with a short code and now I'm looking for a solution that will randomly pick a short code from a list of short codes (one for each of the 20 clips)

Any idea? Anything would help!

Thanks so much for you valuable support!
Pascal

Comments

  • edited April 9 Posts: 391
    Hi Pascal

    To be honest, I did not find a shortcode with this functionality, but maybe you will consider creating one slider with slides in random order?
    Take a look at this tutorial: https://www.snellmitchell.co/knowledgebase-help-support/slider-revolution-5-randomise-slides/ and let me know what you think?

    P.S I found something like this: https://www.themepunch.com/faq/show-a-random-slider-on-any-given-page/ but it looks quite old and I'm not sure if it still works ;)

    With kind regards,
    Daniel
    Post edited by Daniel on
    Lead Graphic Designer
  • Posts: 248
    Hi Daniel


    Thanks for those infos. The issue is that I need to have a two slides slider in order to add the final frame when the clip stops. So I cannot use singles slides within one slider... I actually really need to have randome sliders (each containing two slides)... I have forwarded the second tut (their own :smile: ) to them punch.. let's see what they think?

    The fist tutorial is "weird"? As their already is an option to randomize slides (in one slider) within Revo under geneeral Settings of the slider ("Shuffle" function)...

    Let's see how to solve this issue
    And thanks once more for all the help!
    Pascal
  • Posts: 248
    Hi Daniel
    So, Themepunch confirmed that the php script is working.. here is what they sent me:

    -----
    You need to edit the page.php file of your theme and than you need to add below php code in the page.php file. Page.php file can be found under theme’s root folder

    // get a list of all available sliders
    $my_sliders = new RevSlider();

    // grab the "alias" names of the sliders
    $my_slider_array = $my_sliders->getAllSliderAliases();

    // randomize magic
    $my_slider_keys = array_keys($my_slider_array);
    $my_random_slider_alias = $my_slider_array[$my_slider_keys[rand(0, count($my_slider_keys) - 1)]];

    // add the random slider to the page
    putRevSlider($my_random_slider_alias);

    ----

    Now I'm reaching out to you guys again to make sure I implement that the correct way. Should I use a plugin for the php code (for instance: https://wordpress.org/plugins/my-custom-functions/) And how do I make sure the Sliders will be on the pages (I placed them using short codes so far)?

    Thanks a lot
    Pascal
  • AirAir
    Posts: 10,059
    Hello :-)

    To be honest I don't know why they gave you such a solution when you are planning to use it as part of the Elementor content.

    I think(not sure) I could convert this code to a shortcode, if this code really works, but it requires some time for testing that I don't have today.

    I could try on Monday, however, Mondays are always overloaded with requests from the weekend ;-)

    With kind regards.

  • Posts: 248
    Hey Air

    Thank you so much.. any help is really appreciated! I will finish setting up the test site for this task and will give you access to that if this can help...

    You rock!
    Pascal
  • Posts: 248
    Hello Air

    So I have once more contacted theme punch because of my issue (since it's a Slider Rev issue in the first place) and they are trying to solve my issue.. in case they fail I woud kindly ask for your help again.. but hopefully I won't have to bother you anymore for this?

    As I'm building a new site there will be enough other questions related to rife anyways :wink:
    Thanks, Pascal
  • AirAir
    Posts: 10,059
    Hey :-)

    Thanks for the update on this!

    If anything, please let me know :-)

    With kind regards.
  • Posts: 248
    Hi Air

    We're getting there.. not the best solution yet.. but I think they will manage!
    Of course I already have a new question based on the landing page OneLander II:

    Now the "Tab" in the cener is all the way visible and when scrolling start it get smaller > Is it possible the other way around.. "tab" is small" and only while scrolling the whole "tab" is visible?

    And: Can I change the shape of the "tab"?

    You can see what I'm working on here: https://zauberduo.flyart.com

    Thanks, Pascal
  • Posts: 391
    Hi Pascal

    I assume that the "Tab" is the shield under the logo, right? ;)
    You can change how much the logo should hide here: https://nimb.ws/F2rBgO
    About changing the shape, we don't have more shapes but let me know what you want to put there and I'll consult with .Air :)

    Best,
    Daniel
    Lead Graphic Designer
  • Posts: 248
    Hi Daniel

    Yes.. the shield :wink:
    I probalby didn't explain myself correctly. I'd like to invert the way the shield interacts. I have made quick comps in photoshop to explain better (see attachments).
    I'll look into what shape would fit the best and I'll contact you again for that "issue".

    Thanks a lot, Pascal
    shield-rife-onelander-top-of-page.jpg
    1088 x 1078 - 118K
    shield-rife-onelander-scrolling-sticky-header.jpg
    1088 x 1078 - 120K
    shield-rife-onelander-no-scrolling-sticky-header.jpg
    1088 x 1078 - 116K
  • AirAir
    Posts: 10,059
    Hey Pascal :-)

    Thanks for the screens!

    Sorry but such a thing is not possible. Relaying on scroll event is not an option in the current mobile world.

    My personal opinion is that such behavior would also be very annoying, as it would additionally cover content while scrolling when the user usually scan what they see.

    With kind regards.
  • Posts: 248
    Hey Air

    Thanks for our feedback! I'll come back when (or if) I could try a new shape ;)
  • Posts: 248
    Hey Air

    Well.. Themepunch implemented the php into page.php but didn't manage the create shortcode out of if :neutral: So I'm coming back hoping you can help.. now the random function works fine but it places a clip on the top of every page .. so I cannot decide which page should have it or where to place it on a certain page.. are you still up for helping me?
    Thanks a lot, Pascal
  • AirAir
    Posts: 10,059
    Sure Pascal :-)

    Please send me temporary* access to your WordPress and FTP. Send it here on the forum via private message(click on my nick, in top-right corner you will find option "Message").

    By sending access to WordPress I mean:
    -create a new ADMIN account with a fake e-mail
    -set some password to this account
    -send me created login and password

    *temporary - please delete this account after I am done, for your safety!
  • Posts: 248
    Hi Air

    Thanks a million! You can use the accesses you already have as I didn't change them (since it's a test site anyways)
  • AirAir
    Posts: 10,059
    Hey :-)

    Your shortcode is called [flyart_random_revo].

    I have removed the code from page.php and moved it to child theme functions.php.

    Please check it:-)

    With kind regards.
  • Posts: 248
    Hey Air!
    Once more: you are the man! Fantastic! Thank you so much!
    Pascal
  • Posts: 248
    Hi Air

    I wanted to work onthe site but I cannot work on the page you did as working example in Elementor anymore.. also when I try to place the shortcode into another page and save in elementor I get a server error...
    Could you have a look? Thank you
    Pascal
  • Posts: 248
    and now I got this message:

    Fatal error: Uncaught Error: Call to undefined function putRevSlider() in /home/flyartes/www/zauberduo.flyart.com/wp-content/themes/rife-pro-child-theme/functions.php:39 Stack trace: #0 /home/flyartes/www/zauberduo.flyart.com/wp-includes/shortcodes.php(325): a13rife_random_revo('', '', 'flyart_random_r...') #1 [internal function]: do_shortcode_tag(Array) #2 /home/flyartes/www/zauberduo.flyart.com/wp-includes/shortcodes.php(199): preg_replace_callback('/\\[(\\[?)(a13fe\\...', 'do_shortcode_ta...', '[flyart_random_...') #3 /home/flyartes/www/zauberduo.flyart.com/wp-includes/class-wp-hook.php(286): do_shortcode('[flyart_random_...') #4 /home/flyartes/www/zauberduo.flyart.com/wp-includes/plugin.php(208): WP_Hook->apply_filters('[flyart_random_...', Array) #5 /home/flyartes/www/zauberduo.flyart.com/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1532): apply_filters('the_content', '[flyart_random_...') #6 /home/flyartes/www/zauberduo.flyart.com/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php in /home/flyartes/www/zauberduo.flyart.com/wp-content/themes/rife-pro-child-theme/functions.php on line 39
  • AirAir
    Posts: 10,059
    Yes, because I started debugging. I will reply soon
  • Posts: 248
    THANKS!
  • AirAir
    Posts: 10,059
    Hello :-)

    It looks that Elementor tries to execute shortcode before RevoSlider is loaded. I have added protection for this. However, it seems that now you will not be able to see shortcode working in Elementor, but it will work on the front-end.

    Have a great weekend!

    With kind regards.
  • Posts: 248
    That was super quick.. thanks a lot.. and no problem if I don't see it working in elementor!
    Have a great weekend also!
  • Posts: 248
    Hello Air

    Time to bug you again ;)
    It seems that the php and shortcode trick you did for me doesn't work anymore with the update to rev slider 6? (Still the random slider issue here https://zauberduo.flyart.com) .. it worked like a charm and now after the updates I don't even seen the slider anymore? Could you have a look please (credentials have not changed and should be in messages to you)
    Thanks, Pascal
  • Posts: 248
    And it's me again :)
    Very stupid question I guess.. but using the same template (https://zauberduo.flyart.com) in that site I cannot manage to change the background color of the page.. it doesn't do anything when I change it in Customizer and it doesn't change when I change it in the page details of the actual page.. what I am doing wrong?
    Thanks, Pascal
  • AirAir
    Posts: 10,059
    Hey :-)

    I will take a look at your page and the slider case. However, for your new question please start a new topic, as it will get lost in this bigger issue.

    With kind regards.
  • AirAir
    Posts: 10,059
    Hey :)

    In revo slider 6 they have removed functions that made all things work. Please contact them again, and send them previous code they gave you, and ask for proper version for Revo 6.

    Then I will be able to reimplement it in the shortcode solution.

    As for the thing with page background color - could you mark on the screenshot which area do you mean exaclty. Maybe It is Elementor Row?

    With kind regards.
  • Posts: 248
    Hello Air

    OK.. I thought something like that would happen (and the way Revo 6 works I don't like at all) ... but well.. it is how it is.. I will ask them for a proper PHP code :)

    Thanks, Pascal
  • AirAir
    Posts: 10,059
    You can also downgrade to version 5.x and skip Revo 6 for now. It could be better move with less headaches ;-)

    With kind regards.
  • Posts: 248
    Lol.. that's what I am doing anyways.. but it's good to be ready too :))
  • Posts: 248
    Hi Air

    So this ist what Theme Punch told me:

    I have consulted this issue with dev here and they have updated an article which will help you to upgrade code for V6. Please check out the following article as it explains more about this topic.
    https://www.themepunch.com/faq/developer-guide-get-all-slider-alias/

    Does this help?

    Thank you very much, Pascal
  • AirAir
    Posts: 10,059
    Hey :-)

    It is fixed on your site. I have edited code in functions.php in the child theme.

    With kind regards.
  • Posts: 248
    Hey Air

    You're THE man! Thanks a lot.. Unfortunately I will have to contact you in the coming days again for that as I migrated the beta site to another sub domain to be able to continue work with the old revo slider ... So I will have to know how to implement your code on the other site and update revo there as well ...

    Thanks again!
    Pascal
  • Posts: 248
    PS I wish I could give you guys 6 out of 5 stars!
  • AirAir
    Posts: 10,059
    Thanks ;-)
    Air said: I have edited code in functions.php in the child theme.
    So on your other site just copy content of this file or whole child theme there.

    With kind regards.
  • Posts: 248
    Hey!
    Easy enough, thanks!
    Other question related to the same same you just adapted the random function:
    The client (magicians) have 30 (!) video clips to randomly choose from.. I am looking for the best solution to provides those clips to not slow down the website too much.. youtube? media library? Plugins that help provide faster delivery? Any input is greatly appreciated!

    Thanks a lot Pascal
  • AirAir
    Posts: 10,059
    YouTube is usually the fastest, but it depends on your client server.

    Personally, I would go with YouTube as it does a lot of work for you, like handling the delivery of the video for mobiles in proper formats.

    With kind regards.
  • Posts: 248
    Hey Air

    Thanks for your valuable opinion!

    Have a great evening!
    pascal
  • Posts: 248
    Hi again Air

    I have preceeded to set up a new install to have a good clean start for that site (https://zd.teamswitzerland.com) including revo 6 with your new code.. but whenever I want to preview my sliders I get an ajax error altough when testing the slider it seems to be working.. any idea what this issue is?
    (same credential for login)

    Thanks, Pascal
  • Posts: 248
    Me again :)
    Would you also do a (simple) comissioned revo slider job.. I'm loosing my nerves and would happily spend a little money on a working slider the way I need it :)

    Thanks for you reply
    Pascal
  • AirAir
    Posts: 10,059
    Hello :-)
    FLYART said: but whenever I want to preview my sliders
    Preview on page, or with some feature of revoslider? Slider works fine for me on your page.
    Could you show me a screenshot of what you get?
    FLYART said: Would you also do a (simple) comissioned revo slider job
    Sorry, but I am not available for custom work.

    With kind regards.
  • Posts: 248
    Hi Air

    Thanks for your reply!
    I have also sent a support request to the revo people (since I don't know where the issue comes from) that are apprantly looking at it... so you can wait.. maybe they will solve the problem if not related to Rife...

    Too bad for the comissioned job.. but totally understand it! Thanks anyway!

    Have a great day, Pascal
  • Posts: 248
    Hello once more Air

    So I see my subsrciption to Rife Pro hs happened and I have a little less bad conscience about asking so many questions :)
    Still working on the revo slider.. looking kinda good so far and the random function works lke a charm.. now since it's not being looped I have a "reload" button in the last slide using a callback to refresh the page (window.location.href=window.location.href).. that works... BUT not very elegant as it relaods the whole page but acutally it should only call the random function (shortcode?) to reload a clip randomly instead of reloading the whole page to have a random video chosen.. how could I achieve this? (call your shortcode using js or ...?)
    Thanks a lot Pascal
  • AirAir
    Posts: 10,059
    Hello Pascal:-)

    What you have currently is a very simple callback and it is rather a long way from what you need.

    You will have to:
    1. Call WordPress backend for ajax action.
    2. In this action call shortcode to generate new revo slider.
    3. On frontend replace the current slider with new slider.
    4. Start a new slider with some JavaScript action.

    This is not a trivial task, but possible for someone to program if he/she knows RevoSlider & WordPress APIs well enough.

    However, if you are looking to load another slider after this one is done playing, then it sounds like it defeats the purpose of the random slider that you started with.

    I would rather make bigger sliders with 3 "movies" each, for example, and rotate those sliders on each page load.

    This way user would not have to click to be entertained again and you will have more content.

    With kind regards.
  • Posts: 248
    Hi Air

    Thanks for your extensive reply.
    Yes, the idea would have been to only load the random funtions shortcode to randomly replace the slider with another without having to refresh the page.
    But given your reply this is way out of scope for that project.. they will have to live with the page refresh :) Or I'll tell them about the idea of have 3 clips in each slider..

    Thanks, Pascal
  • Posts: 248
    Hi again Air

    I have finally moved the page to my client but it looks like the random function you made for me doesn't work anymore? Although your short code is being used and thus the php code has to be running every page keeps it's own clip ... can you please help?
    Access is coming though private message...

    Thanks a lot
    Pascal
  • Posts: 248
    Hi again and again Air

    Sorry.. I found the "issue".. server side caching was activated and therefore rendering a static page ...

    Thanks, Pascal
  • AirAir
    Posts: 10,059
    Great:-) Thanks for the fast feedback!

    With kind regards.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!