Want to assign the Article_ID in a template! How to call....

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Bobo
Posts: 13
Joined: Tue 18. Jan 2005, 03:06
Contact:

Want to assign the Article_ID in a template! How to call....

Post by Bobo »

Hi Folks,

I want to assign the article_ID inside a list template. I am using the same inside the view template:

Code: Select all

[PHP]echo "<img border=\"0\" src=\"picture/"."".$GLOBALS['content']['article_id']."_galery.jpg\" >";[/PHP]
This works fine!!!
It seems that I have to use other parameters inside the listview. Because using the above code, the rewturned value is empty!

Look at the properties of the first article at http://www.ringelimmobilien.de/index.php?offers.

The filename should be .../10_galery.jpg...

Someone can help out???

Best regards

Bobo
brans

Post by brans »

http://www.phpwcms.de/forum/viewtopic.php?t=5513

watch this thread for further information.
Bobo
Posts: 13
Joined: Tue 18. Jan 2005, 03:06
Contact:

This one I know...

Post by Bobo »

brans wrote:http://www.phpwcms.de/forum/viewtopic.php?t=5513

watch this thread for further information.
Hi brans,

this one I know, but it doesn't help... I suppose that I only have to modify "content" or to add another ['statement'] between. But I dont know which on...

Code: Select all

$GLOBALS['content']['statement']['article_id']
brans

Post by brans »

no I guess that you are completely wrong. These replacement-tags inside the templates are rendered on a very static way.

I mean really watch this thread, if you don't understand thatone, then you will probably have to ask someone else to come up with a solution for you
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

This way - $content['article_id'] does not exist when in list mode. But better do a check as bottom.

Code: Select all

[PHP]
$_cur_articleID = empty($GLOBALS['content']['article_id']) ? $GLOBALS['aktion'][1] : $GLOBALS['content']['article_id'];
echo '<img src="picture/'.$_cur_articleID.'_galery.jpg" border="0">';
[/PHP]
Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Bobo
Posts: 13
Joined: Tue 18. Jan 2005, 03:06
Contact:

Your code Snipp...

Post by Bobo »

Oliver Georgi wrote:This way - $content['article_id'] does not exist when in list mode. But better do a check as bottom.

Code: Select all

[PHP]
$_cur_articleID = empty($GLOBALS['content']['article_id']) ? $GLOBALS['aktion'][1] : $GLOBALS['content']['article_id'];
echo '<img src="picture/'.$_cur_articleID.'_galery.jpg" border="0">';
[/PHP]
Oliver
First of all thank you for your assitance, but the value which will be returned by using the above code is "0". Just look at the picture properties of the first article at http://www.ringelimmobilien.de/index.php?offers

Best regards so far...

bobo
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

you can not use it in this way!!! This will always return 0 because listing does not have an article ID.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Bobo
Posts: 13
Joined: Tue 18. Jan 2005, 03:06
Contact:

???

Post by Bobo »

Oliver Georgi wrote:you can not use it in this way!!! This will always return 0 because listing does not have an article ID.

Oliver
OK, I understand! To explain a little bit more my intenntion of use: I want lets say automatically assign a picture to the custom template. I thought that it is easy because I use a similar way in the vie template of each article, which look for 2 pictures like "articleid_leftpicture.jpg" and the same for the right on.... And due to that you are creating Tags like "Articlelink" it must be possible, or??? ;-)
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

OK - small patch in front.func.inc.php in function list_articles_summary()

after:

Code: Select all

//rendering
$tmpl = $tmpllist[ $article_list[$key]["article_image"]['tmpllist'] ];
paste in:

Code: Select all

$tmpl = render_cnt_template($tmpl, 'EDITOR', $article_list[$key]["article_username"]);
$tmpl = render_cnt_template($tmpl, 'ARTICLEID', $article_list[$key]["article_id"]);
New Tag for list template: ARTICLEID and EDITOR

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Bobo
Posts: 13
Joined: Tue 18. Jan 2005, 03:06
Contact:

Thanx a lot!!!

Post by Bobo »

Oliver Georgi wrote:OK - small patch in front.func.inc.php in function list_articles_summary()

after:

Code: Select all

//rendering
$tmpl = $tmpllist[ $article_list[$key]["article_image"]['tmpllist'] ];
paste in:

Code: Select all

$tmpl = render_cnt_template($tmpl, 'EDITOR', $article_list[$key]["article_username"]);
$tmpl = render_cnt_template($tmpl, 'ARTICLEID', $article_list[$key]["article_id"]);
New Tag for list template: ARTICLEID and EDITOR

Oliver
Thanx a lot Oliver....

It works like a charme....

Best regards from Hamburg

Bobo
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post by marcus@localhorst »

Holla,

I need the article_id and the article_title in the frontend_render.
how do i get this?

thanks marcus
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

This is very easy

You can access catID and articleID (as long as not in list mode) like this:

catID:

Code: Select all

$GLOBALS['aktion'][0];
$GLOBALS['content']['cat_id'];
articleID:

Code: Select all

$GLOBALS['aktion'][1];
$GLOBALS['content']['article_id'];
articleTitle should be (when not in list mode):

Code: Select all

$GLOBALS['content']['articles'][$GLOBALS['aktion'][1]]['article_title'];
Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post by marcus@localhorst »

i need it both modes :?
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

But it does not exist for both modes - when you are in list mode there is NO article ID and if no article ID no title exists.

Or what do you mean?

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
marcus@localhorst
Posts: 815
Joined: Fri 28. May 2004, 11:31
Location: localhorst
Contact:

Post by marcus@localhorst »

the example:

i try to build a simple cart. each article in a category is a product.
with a replacementtag i build the form button, to add an article to cart.
i will send the article_id and article_title as POST variables. and so i thought i detect the article_id inside the frontend_render.
hope you know what i mean. (ich könnt es auch in deutsch schreiben ;-) mein englisch ist nicht so gut.)

jeder CMSartikel ist ein Shopartikel. Mit einem Replacementtag möchte ich den "in warenkorb hinzufügen" button generieren (das Tag wird im frontend_render ordner geparst. Dort brauche ich den artikeltitel und die id. diese übergebe ich dann an die addtocart funktion um id und titel in einem array zu speichern.

ich hoffe ich konnte es einigermaßen erklären.
grüße marcus
Post Reply