What is the variable $vars['item'];?

I'm trying to use this variable on JavaScript but I can't because this variable seems empty, I'm trying this too:

echo $vars['item'];

and the result is nothing. I need this variable working in a Ajax php view but I just can use the GUID because I can echo $guid; but I can't echo $vars['item']; I don't know why

  • Did you see the ref on $vars['item']

    Not sure whether this will help you at all but here are the links
    http://learn.elgg.org/en/latest/guides/river.html
    http://reference.elgg.org/river_2elements_2body_8php.html
    http://reference.elgg.org/river_2elements_2summary_8php.html

     

    BTW, is it possible to change your icon/photo :-)  Thanks.

  • Dranii is correct. That variable gets populated only in the river view on the server side.

    In which view are you trying to access it?

  • @juho.jaakkola I'm trying to call a River view with Ajax, It's done, I made it, but not the entire view because it is not possible to use the variable $vars['item']; on JavaScript. I don't understand why I can't echo this variable on the river, it supose to work on river right? But if I try to do this:

    echo $vars['item'];

    don't shows anything.

    The hypeScraper Ajax load is finally working with this code on file river view:

    /**
     * File river view.
     */

    $object = $vars['item']->getObjectEntity();
    $objeto = $object->guid;
    $excerpt = strip_tags($object->description);
    $excerpt = thewire_filter($excerpt);

    $excerpt .= "<div class='elwire-$objeto'></div>";

    $subject = $vars['item']->getSubjectEntity();
    $subject_link = elgg_view('output/url', array(
        'href' => $subject->getURL(),
        'text' => $subject->name,
        'class' => 'elgg-river-subject',
        'is_trusted' => true,
    ));

    $object_link = elgg_view('output/url', array(
        'href' => "thewire/owner/$subject->username",
        'text' => elgg_echo('thewire:wire'),
        'class' => 'elgg-river-object',
        'is_trusted' => true,
    ));

    $summary = elgg_echo("river:create:object:thewire", array($subject_link, $object_link));


    echo elgg_view('river/elements/layout', array(
        'item' => $vars['item'],
        'message' => $excerpt,
        'summary' => $summary,
    ));

    $urll =  elgg_get_site_url();

    echo "<script>

    $(document).ready(function() {

    $.get('$urll/ajax/view/aalborg_theme/cargaow' ,
       {objeto: '$objeto'
        }, 
        function(data) {
        
        $('.elwire-$objeto').html(data);  

    });   


    });
    </script>";

    And this code on the Ajax view:

     

    $objeto = $_GET['objeto'];
    $object = get_entity($objeto);

    $excerpt = elgg_get_excerpt($object->description);
    $uvoo = parse_urls($excerpt);
    $uvo =  strip_tags($uvoo);

    if (elgg_view_exists('output/url_preview')) {

    echo elgg_view('output/url_preview', array('value' => $uvo));

    }

    So, now the hypeScraper URL views are loading after the page is fully loaded, but this is not working on River Adon wires because River Adon is not loading the <script></script> I don't know why, I suppose it's a JS filter but I can't find it.

     

    @dranii I don't understand the icon/photo issue.