1

quiero traer las categorías que ya están registradas y los contactos lo cual no lo esta haciendo tengo el siguiente código:

function listContacts( $option, $catid ) {
    global $mainframe, $database, $my;
    global $mosConfig_live_site;
    global $Itemid;

    /* Query to retrieve all categories that belong under the contacts section and that are published. */
    $query = "SELECT *, COUNT( a.id ) AS numlinks"
    . "\n FROM #__categories AS cc"
    . "\n LEFT JOIN #__contact_details AS a ON a.catid = cc.id"
    . "\n WHERE a.published = 1"
    . "\n AND cc.section = 'com_contact_details'"
    . "\n AND cc.published = 1"
    . "\n AND a.access <= " . (int) $my->gid
    . "\n AND cc.access <= " . (int) $my->gid
    . "\n GROUP BY cc.id"
    . "\n ORDER BY cc.ordering"
    ;

    $database->setQuery( $query );

    $categories = $database->loadObjectList();

    $count = count( $categories );

    if ( ( $count < 2 ) && ( @$categories[0]->numlinks == 1 ) ) {
        // if only one record exists loads that record, instead of displying category list
        contactpage( $option, 0 );
    } else {
        $rows       = array();
        $currentcat = NULL;

        // Parameters
        $menu = $mainframe->get( 'menu' );
        $params = new mosParameters( $menu->params );

        $params->def( 'page_title',         1 );
        $params->def( 'header',             $menu->name );
        $params->def( 'pageclass_sfx',      '' );
        $params->def( 'headings',           1 );
        $params->def( 'back_button',        $mainframe->getCfg( 'back_button' ) );
        $params->def( 'description_text',   _CONTACTS_DESC );
        $params->def( 'image',              -1 );
        $params->def( 'image_align',        'right' );
        $params->def( 'other_cat_section',  1 );
        // Category List Display control
        $params->def( 'other_cat',          1 );
        $params->def( 'cat_description',    1 );
        $params->def( 'cat_items',          1 );
        // Table Display control
        $params->def( 'headings',           1 );
        $params->def( 'position',           1 );
        $params->def( 'email',              0 );
        $params->def( 'phone',              1 );
        $params->def( 'fax',                1 );
        $params->def( 'telephone',          1 );

        if( $catid == 0 ) {
            $catid = $params->get( 'catid', 0 );
        }

        if ( $catid ) {
            $params->set( 'type', 'category' );
        } else {
            $params->set( 'type', 'section' );
        }

        if ( $catid ) {
            // url links info for category
            $query = "SELECT *"
            . "\n FROM #__contact_details"
            . "\n WHERE catid = " . (int) $catid
            . "\n AND published =1"
            . "\n AND access <= " . (int) $my->gid
            . "\n ORDER BY ordering"
            ;
            $database->setQuery( $query );
            $rows = $database->loadObjectList();

            // current category info
            $query = "SELECT id, name, description, image, image_position"
            . "\n FROM #__categories"
            . "\n WHERE id = " . (int) $catid
            . "\n AND published = 1"
            . "\n AND access <= " . (int) $my->gid
            ;
            $database->setQuery( $query );
            $database->loadObject( $currentcat );

            /*
            Check if the category is published or if access level allows access
            */
            if (!$currentcat->name) {
                mosNotAuth();
                return;
            }
        }

        // page description
        LINEA 147 $currentcat->descrip = '';
        if( isset($currentcat->description) && ($currentcat->description != '') ) {
            $currentcat->descrip = $currentcat->description;
        } else if ( !$catid ) {
            // show description
            if ( $params->get( 'description' ) ) {
                $currentcat->descrip = $params->get( 'description_text' );
            }
        }

        // page image
        $currentcat->img = '';
        $path = $mosConfig_live_site .'/images/stories/';
        if ( isset($currentcat->image) && ($currentcat->image != '') ) {
            $currentcat->img = $path . $currentcat->image;
            $currentcat->align = $currentcat->image_position;
        } else if ( !$catid ) {
            if ( $params->get( 'image' ) != -1 ) {
                $currentcat->img = $path . $params->get( 'image' );
                $currentcat->align = $params->get( 'image_align' );
            }
        }

        // page header
        $currentcat->header = '';
        if ( isset($currentcat->name) && ($currentcat->name != '') ) {
            $currentcat->header = $params->get( 'header' ) .' - '. $currentcat->name;
        } else {
            $currentcat->header = $params->get( 'header' );
        }

        // used to show table rows in alternating colours
        $tabclass = array( 'sectiontableentry1', 'sectiontableentry2' );

        HTML_contact::displaylist( $categories, $rows, $catid, $currentcat, $params, $tabclass );
    }

No identifico donde se encuentra el inconveniente link donde se ve el error http://www.ecoversa.org/index.php?option=com_contact&Itemid=3&lang=sp

4
  • ¿qué hay en la línea 147 de components/com_contact/contact.php ?
    – Shaz
    Commented el 27 feb. 2018 a las 22:00
  • si mira la linea esta en el fragmento de código // page description $currentcat->descrip = ''; Commented el 27 feb. 2018 a las 22:39
  • 1
    Según ese error, lo más probable es que $catid no esté definido o que estés proporcionando un valor que no existe en dicha tabla.
    – Shaz
    Commented el 27 feb. 2018 a las 23:00
  • mira al principio de la función esta definida la variable , y en la bases de datos esta por id Commented el 27 feb. 2018 a las 23:30

1 respuesta 1

1

El problema es sencillo de resolver, simplemente estás intentando asignar un valor a un elemento cuyo valor es null:

$currentcat = NULL;

...

$currentcat->descrip = '';

Debes definir primero el objeto de la clase correspondiente, antes de asignarle cualquier valor:

$currentcat = new \ObjetoClass(); // de la clase que sea

...

$currentcat->descrip = '';

Según la documentación de Joomla, el argumento que pasas a loadObject debe ser un string, el cual será el nombre de la clase que se utilizará para el objeto entregado:

loadObject

Method to get the first row of the result set from the database query as an object.

loadObject(string $class = 'stdClass') : mixed

https://api.joomla.org/cms-3/classes/JDatabaseDriver.html#method_loadObject

1
  • gracias por tu ayuda Commented el 28 feb. 2018 a las 16:33

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.