Judah Raine
Total posts: 332
25 Нояб 2012 01:35

I have spent an entire day sifting through templates and still cannot find the dratted "> that appears as follows:

I have identified it (I think) on Firebug as being part of the url field:

I am trying to achieve this:

You copy and edit fields templates and ensure that field image return only image and field URL only URL withut HTML. Then in template

fields_by_id[10]->result, $item->fields_by_id[12]->result);?>

where 10 is ID of the URL field and 12 is and ID of the image field.

I am using the gallery field and not the image field, and am still trying to work out how to get the url to output only url without html, but have now been sidetracked with the dratted ">!!

I have thus far only copied the default url output file and called it headerbanner.php, but not changed anything at all.

I am using an input template which I have used for a few other things and which has not brought this "> into anything else, so my assumption is that it's not the input field that's the problem.

That really only leaves the article template, which I've attached. If anyone can spot this - and you probably will first time off - I would be very grateful. I now feel like a complete and utter idiot, and have avoided asking this question... Yes, I'm a dork, so sorry. (But a desperate dork)

Another method is to parse string in article/article list template.

Последние изменения: 02 Март 2014


Sackgesicht VIP
Total posts: 1,636
25 Нояб 2012 04:49

Judah,

Please explain, what you exactly want the URL field to display in this line, i did not get it yet.


pepperstreet VIP
Total posts: 3,837
25 Нояб 2012 06:57

Are you sure that line 133 with JHtml... has the correct field values? I guess, the whole output seems messed-up. Please, ...

  • check both field's contents
  • check JHtml structure and needed parameter Syntax

pepperstreet VIP
Total posts: 3,837
25 Нояб 2012 07:01

As Sergey mentioned in your other topic...

"... ensure that field image return only image and field URL only URL without HTML. Then in template ...

<?php echo JHtml::link($item->fields_by_id[10]->result, $item->fields_by_id[12]->result);?> 

Otherwise, you mess-up your source and your browser tries to "repair" and interprete it somehow.


Judah Raine
Total posts: 332
25 Нояб 2012 07:40

I have to confess that at this point I no longer have any clue what I'm doing ._. I have been going over these dratted things for so long now that I cannot remember what I've done, what I've checked.... sigh.

My field values at least are right - gallery field is 50, url field is 51. I just checked that.

Basically what I'm trying to do is have an advertiser upload a banner image with a url, i.e. the banner image is the gallery field, and I need the the article to show as simply the banner with an embedded link (i.e. the url)

As I had not yet worked out how to change the fields, I was just checking that they displayed ok as two separate fields, when the "> appeared. It seems logical to me that this must be some extraneous code or something that is visible because it's wrongly stated in the template, but for the life of me I cannot find where or how - I thought once I found and deleted those I could move onto the next step.

Most likely I'm doing things backwards, but I always try to work from a point of what I know to then learning what I don't know., and there seems little point in moving on to trying to alter the fields if the extra "> is likely to mess up the link anyway?


Sackgesicht VIP
Total posts: 1,636
25 Нояб 2012 21:03

Judah,

first take a look at the Joomla documentation here and then try to understand the difference between a

 $item->fields_by_id[XX]->result

and

$item->fields_by_id[XX]->value

$item->fields_by_id[XX]-> result **holds the HTML output (defined by the output template) and $item->fields_by_id[XX]->value** holds the value(s) stored in the database.

Just be aware that $item->fields_by_id[XX]->value can hold a string or an array (depending on the field type).

The best way to find out what is "available" to you, is by using the Jdump utility (as adviced before).

Will post later more detailed ...


Judah Raine
Total posts: 332
25 Нояб 2012 22:08

Hi guys, sorry, I'm afraid I succumbed to a sinus attack yesterday - too many loooong hours. I will have another look at this today. I do appreciate the help and suggestions


Sergey
Total posts: 13,748
25 Нояб 2012 22:22

This is because

$item->fields_by_id[XX]->result

Contain html like SOmethign but not only URL as you try to use it.

I suggest you to do this

echo htmlspecialchars($item->fields_by_id[XX]->result);

And you will see what is in the variable.


Judah Raine
Total posts: 332
01 Дек 2012 23:55

Hmmm.... I'm now trying to pick up where we left off, a week later, and not sure where to begin...

I think my error is that I need to output the url as text as you indicated in a previous topic before I can hope to have this display properly.

I've looked at the output template and find this:

value; $options = $this->params->get('params.open_url', 1) ? ' target="_blank"' : ''; if (count($value) == 1) : ?>
<?php echo JHtml::link('http://' . $value[0]['url'], ($value[0]['label'] != '' ? $value[0]['label'] : $value[0]['url']), $options);?>

From this I gather that the part I need to change is:

<?php echo JHtml::link('http://' . $value[0]['url'], ($value[0]['label'] != '' ? $value[0]['label'] : $value[0]['url'])

Would I make this echo tex rather than link? Please forgive my ignorance.


Sergey
Total posts: 13,748
02 Дек 2012 00:00

You can just do this

<?php

$value = $this->value;

echo 'http://' . $value[0]['url'];

That is it. You will get only URL.


Judah Raine
Total posts: 332
02 Дек 2012 01:29

Thank you this has resolved the url issue. I have now gone back to the previous topic where you explained how to output only image as follows:

In image output template at line 66 you can find

$url =  sprintf('%s/thumbs_cache/image/%s', $this->url, $new_name);



$html_img = JHTML::image($url, @$value['image_title'],  array('hspace' => $this->params->get('params.img_hspace'), 'vspace' => $this->params->get('params.img_vspace'), 'title' => @$value['image_title']));

YOu have to change it to

$url =  sprintf('%s/thumbs_cache/image/%s', $this->url, $new_name);



echo JHTML::image($url, @$value['image_title'],  array('hspace' => $this->params->get('params.img_hspace'), 'vspace' => $this->params->get('params.img_vspace'), 'title' => @$value['image_title']));



return;

You can also delete any code after return. This is how you output only image.

The problem here is that I am using the gallery field, and when I go to the output file I can find nothing that remotely resembles this. The only code present in output file full.php is as follows:

record = $record; $this->_init(); ?> params->get('params.thumbs_resize_mode', 1) == 1): ?>
<?php echo $this->_auto();?>
<?php echo $this->_custom(); ?>

Sergey
Total posts: 13,748
02 Дек 2012 07:06

I was referring to list.php


Judah Raine
Total posts: 332
02 Дек 2012 09:02

hmmm... I'm not sure I understand how list.php would influence the full article output?


Sergey
Total posts: 13,748
02 Дек 2012 20:37

You can set it for full view. It is parameter.If you need only URL of only one image then you can use the same field template for list and for view.


Judah Raine
Total posts: 332
02 Дек 2012 21:58

Ah, that makes sense, thank you:D


Judah Raine
Total posts: 332
02 Дек 2012 23:07

Thank you, I have found and amended the code in the list.php. In my article template I have added the

fields_by_id[51]->result, $item->fields_by_id[50]->result);?>

where 51 is ID of the URL field and 50 is and ID of the image field.

Problem is that the following link displays with the image (i.e. when you hover over image)

http://www.classicromancerevival.com/index.php?option=com_cobalt& ;view=record&id=30:judah-raine&Itemid=658

Which is obviously the article url and not the link I need embedded into the image. To clarify, the image is uploaded along with a url. I need the article to display only the image, but the link when image is clicked directs user to the url that was uploaded.

So sorry, perhaps I've missed something along the way?


Sergey
Total posts: 13,748
03 Дек 2012 00:13

Show me what is in your 50 field output template.


Sergey
Total posts: 13,748
03 Дек 2012 00:15

And why do you need link to article inside the article? It means link o itself. Or I miss something?


Sergey
Total posts: 13,748
03 Дек 2012 06:35

First file is not full. Just attach it instead of inserting as text. And files look original. What was your changes?


Judah Raine
Total posts: 332
03 Дек 2012 08:10

Files attached. The change in the url file is the firs php section as follows:

value; echo 'http://' . $value[0]['url']; if (count($value) == 1) : ?>

The change in the image file is the very last bit of code at the end of the file.

Thanks!


Sergey
Total posts: 13,748
04 Дек 2012 07:37

file bannerheader.txt have to have only

<?php

$value = $this->value; 

echo 'http://' . $value[0]['url']; 

return;

Did you test? Does $item->fields_by_id[50]->result display picture and $item->fields_by_id[51]->result shows URL?

Работает на Cobalt