Last year, I was making an online newspaper with Joomla, and I had to be able to send images as article parameters. Why? Because if you're only able to insert images into the article body, then you're quite handicapped when it comes to placing that images in a newspaper design. I wanted a frontpage where my article image was on top, then my author name and date, and then came the article text. This was not possible when inserting the article image into the article text.
What I found out was, that it's actually quite simple. All you have to do is locate the file: administrator/components/com_content/models/article.xml.
In this file is an XML list with all article parameters. If you want to be able to select an image from your default images/stories directory, then simply put this line into the "Advanced" group:
<params group="advanced">
<!--This is the line -->
<param name="articleimage" type="imagelist" directory="/images/stories"
hide_default="1" default="" label="Article Image" description="Image" />
<!-- End of line-->
Now, in your layout files inside of the html folder in your template, you're able to use this parameter to display the image whereever you want to. This is how you get the path to the image:
<?php if ($this->item->params->get('articleimage')) : ?>
<img src="/images/stories/<?=$this->item->params->get('articleimage')?>" />
<?php endif; ?>
It's a neat way to be able to control your images, and remember that you can make as many custom parameters as you want!



Now I will try to have automatic article field filled based on category (now I have to do manually)...not easy for my knowledge, considering sect and cat have only menu param but that's it!
I'm not able to write code here, but in the second code I suppose there is a misspelling between stories/ and $this
Kind regards
FabZ
[?php if ($this->params->get('articleimage')) : ?]
[img src="/images/stories/[?php echo $this->params->get('articleimage'); ?]" /]
[?php endif; ?]
alt="[?php echo $this->escape($this->article->title); ?]"
I don't know where the"layout files in the html folder in my template" are.
It would be great if someone could clarify. Thank you!
params->get('articleimage')?>" />
"
Thanks! I am keeping my fingers crossed.
I added the original information avove and received a page error, then added the 2nd and 3rd pieces from the comments and the page displays but with the following code in the article"[?php if ($this->params->get('articleimage')) : ?] [img src="/images/stories/[?php echo $this->params->get('articleimage'); ?]" /];alt="[?php echo $this->escape($this->article->title); ?]" [?php endif; ?]"
What am I doing wrong?
You need to replace all [ and ] with the right character, the chevron character. Google on php tags to see the correct way to write them.
To get the second part working, add it to the following file: components\com_content\views\article\tmpl\default.php just after the canedit var declaration, on the top. This way it'll be displayed above all titles etc.