How to add lightbox effect to a link?

I want to put a light box effect to a single <a href> link...

on clicking a link in THE sidebar a test.php file has to be loaded from views/default/page/elements/ folder is that possible?

advance thanks for your help....

  • Just add the class "elgg-lightbox" to the link

  • @Matt Beckett, Thank you very much....

  • Hi, I've been fighting against the ELGG lightbox since two weeks ago and I cannot find any solution to my problem.

    I have a widget that lists several resources (among them quizzes). These quizzes are provided by a web service. I need that when the user clicks on some of these resources, a lightbox will be opened with the corresponding resource printed.

    My idea is to create a view that request to the web service and prints the output. But I'm having problems with the lightbox. The view loaded in the lightbox does not recognise my libraries (curl) but it does not recognise any elgg function neither.

    This is my code -

    widget:

    $url = "/mod/whiteboard/views/default/lightbox/quiz.php";
                   
    $link = elgg_view('output/url', array(
        'href' => $url,
        'text' => 'test',
        'class' => 'elgg-lightbox',
        'is_trusted' => true,
    ));
    echo $link;

    view:

    echo elgg_get_logged_in_user_entity()->username;

    -

    The result is a link that points to the url but when I click on it, a lightbox is opened with the following message: The requested content cannot be loaded. Please try again later.

    If I try to create a new object curl, the same happens (I've loaded correctly this library cause I've been using it in other places). If I call to the elgg_echo function, the same happens. So, it looks like I'm out of the context of elgg.

    What is happening?

    Thanks.

  • Register your view to be ajax accessible

    http://reference.elgg.org/1.8/views_8php.html#a7ebabcaaa920922e82a1220efbd907e1

    elgg_register_ajax_view('lightbox/quiz');

     

    Then make the url = {domain}/ajax/lightbox/quiz

  • Thank you Matt, you solve my problem!!

    I'm trying now to change the onClosed event of the fancybox but I don't get it!!

    I'm just able to close the fancybox using this instruction $.fancybox.close(); But how can I change the onClosed event of my ELGG fancybox??

    $.fancybox({'onClosed': function () {
            close_fancybox();
        },
    });

    This does not work!! It opens a new fancybox...

    Do you have any idea?

    Thank you very much.