Page 1 of 1

Accessing / checking something in com_content...

Posted: Mon Dec 10, 2007 12:40 pm
by nimzie
I've changed my output for the most part to be semantically correct within com_content. Trying to stick to the basic H / P tags for formatting and keeping things in tidy DIVs. So, with that - I want to change the function "show" in content.html.php.

I want to basically ask:

Is the "show title on"
If so, show the $row->title.

I've tried this, but I don't think I'm doing the right thing:


if ($row->item_title == 1 )
  {
    echo "

" . $row->title . "

";
  }

Maybe I'm using incorrect syntax. Maybe I'm looking at the wrong variable. This is a bit mysterious to me as it's my first trip through the chasms of code that is joomla.

The object $row is mosParameters. When I do a print_r on it ($row), I get :

Code: Select all

stdClass Object
(
    [id] => 25
    [title] => Lorem Ipsum Products
    [title_alias] => Lorem Ipsum Products
    [introtext] => <p>Proin justo tellus, elementum sit amet, aliquam ut, convallis nec, lectus. Integer quam justo, nonummy eget, eleifend ut, facilisis vel, est. Curabitur eget leo non tellus ullamcorper pharetra. </p>
    [fulltext] =>
    [state] => 1
    [sectionid] => 9
    [mask] => 0
    [catid] => 24
    [created] => 2007-12-06 12:35:40
    [created_by] => 62
    [created_by_alias] =>
    [modified] => 2007-12-06 22:23:43
    [modified_by] => 62
    [checked_out] => 0
    [checked_out_time] => 0000-00-00 00:00:00
    [publish_up] => 2007-12-06 12:34:34
    [publish_down] => 0000-00-00 00:00:00
    [images] =>
    [urls] =>
    [attribs] => pageclass_sfx=
back_button=
[color=red]item_title=1[/color]
link_titles=
introtext=1
section=0
section_link=0
category=0
category_link=0
rating=
author=
createdate=
modifydate=
pdf=
print=
email=
keyref=
docbook_type=
    [version] => 2
    [parentid] => 0
    [ordering] => 1
    [metakey] =>
    [metadesc] =>
    [access] => 0
    [hits] => 0
    [author] => Administrator
    [usertype] => Super Administrator
    [category] => Private Banking
    [section] => Products
    [groups] => Public
    [sec_pub] => 1
    [cat_pub] => 1
    [sec_access] => 0
    [cat_access] => 0
    [sec_id] => 9
    [cat_id] => 24
    [prev] =>
    [next] =>
    [text] => <p>Proin justo tellus, elementum sit amet, aliquam ut, convallis nec, lectus. Integer quam justo, nonummy eget, eleifend ut, facilisis vel, est. Curabitur eget leo non tellus ullamcorper pharetra. </p>

)


It seems like a pretty easy if then echo thing but I may be just a little off in my approach. Any help is appreciated.

Cheers,

Adam

Re: Accessing / checking something in com_content...

Posted: Tue Dec 11, 2007 12:51 pm
by nimzie
I tried this:

Code: Select all

      $istitle = $row["item_title"];
      echo 'istitle is ..... ' . $istitle;
      exit;


and got this.

Code: Select all

Fatal error: Cannot use object of type stdClass as array in C:\xampp\htdocs\xampp\joomla\components\com_content\content.html.php on line 826


if I output:

Code: Select all

      $istitle = $row->item_title;
      echo 'istitle is ..... ' . $istitle;
      exit;
   


I get : istitle is .....

When I see above in the object output, I have 1 for the setting.

I've even tried $row.item_title;

I think that may be closer but there is some PHP error telling me I can't do so and so with a string:
Catchable fatal error: Object of class stdClass could not be converted to string in C:\xampp\htdocs\xampp\joomla\components\com_content\content.html.php on line 826

That leads me to think I should be converting this to a string? I'm sure there has GOT to be a prettier way to do this .. No?!

Thanks for any help.

Adam

Re: Accessing / checking something in com_content...

Posted: Thu Dec 13, 2007 12:10 pm
by nimzie
I am still checking this out. I find it odd that I am having a hard time with this.

In content.html.php - in the show function... I want to ask if show title for the article is on .. if so, do something.

How hard can that be? ... hmm... well, I haven't figured it out yet.

$params->get gets me the param, however that is not for the article itself. Apparently from what I see in debugging things, $row is the object I want to check in.

Pretty please! Someone help!!

Re: Accessing / checking something in com_content...

Posted: Fri Dec 14, 2007 8:02 am
by Urme
Wouldn't this work (Joomla 1.0.13):

Code: Select all

if ( $params->get( 'item_title' ) ) {
 echo $row->title;
}