Keyword

Get article id

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar Topic Author
  • Offline
  • Junior Member
More
15 years 1 month ago #81749 by Tiago Manuel da Costa Silva
Get article id was created by Tiago Manuel da Costa Silva
Hi, i´m trying to put a pdf button, how can i get the id of the article i´m in?

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
15 years 1 month ago #81750 by Yiota
Replied by Yiota on topic Get article id
How about using something like this: echo JRequest::getInt('id');

Please Log in or Create an account to join the conversation.

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar Topic Author
  • Offline
  • Junior Member
More
15 years 1 month ago #81751 by Tiago Manuel da Costa Silva
Replied by Tiago Manuel da Costa Silva on topic Get article id
Thanks a lot...

Please Log in or Create an account to join the conversation.

More
15 years 3 weeks ago #81752 by Simon Wells
Replied by Simon Wells on topic Get article id
Can you explain a little more about how/where to use echo JRequest::getInt('id'); so others can use it?
Please.

Simon

Please Log in or Create an account to join the conversation.

More
15 years 3 weeks ago #81753 by Simon Wells
Replied by Simon Wells on topic Get article id
Thanks, unfortunate Ning strips out the code ;(
Can you mail to support at k2joom dot com I will take a look and see if I can get that working as well.

Tiago Manuel da Costa Silva said:Of course Simon.
The thing i did is temporary, because what i did was changing the print button for a pdf button.
Later i want to have a new button but i don´t know how to do it yet.
ok.

Procedure:
1º - I edit the file C:\xampp\htdocs\joomla\components\com_k2\templates\default\item.php
2º - I change the original code:




item->printLink; ?>" onclick="window.print();return false;">



item->printLink; ?>" rel="{handler:'iframe',size:{x:900,y:500}}">





For this code:





&lang= ','mywindow','width=800,height=400'
);return false;">




With this code i open the file i want, in my case to make the pdf (oh, I´m using FPDF), then i get the id of the article and the language so i can use $_GET on the "FILE TO OPEN", and print categories and extrafields on the pdf.


I don´t know if it the best way, but is working. Hope this can help.

Please Log in or Create an account to join the conversation.

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar Topic Author
  • Offline
  • Junior Member
More
15 years 3 weeks ago #81754 by Tiago Manuel da Costa Silva
Replied by Tiago Manuel da Costa Silva on topic Get article id
Sorry for the you can´t see the code, i will send it to you.

Please Log in or Create an account to join the conversation.

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar Topic Author
  • Offline
  • Junior Member
More
15 years 3 weeks ago #81755 by Tiago Manuel da Costa Silva
Replied by Tiago Manuel da Costa Silva on topic Get article id
Simon, i´m always getting : Sorry, Your uploaded file type is not allowed

How can i send the file to you?

Please Log in or Create an account to join the conversation.

More
15 years 3 weeks ago #81756 by Simon Wells
Replied by Simon Wells on topic Get article id
I have added you as a friend, when you accept, I will send you an email address so that you can email a zip file.

Simon

Tiago Manuel da Costa Silva said:Simon, i´m always getting : Sorry, Your uploaded file type is not allowed
How can i send the file to you?

Please Log in or Create an account to join the conversation.

More
15 years 3 weeks ago #81757 by AdrianK
Replied by AdrianK on topic Get article id
JRequest filters the POST and GET for security reasons and give it back. $_SERVER or $_POST was sended by formulars, get via URL, getint converts the value from string to an integer number. You can you use JRequest everywhere in PHP in a "mounted" Joomla, take a look on joomla docs.

Please Log in or Create an account to join the conversation.

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar Topic Author
  • Offline
  • Junior Member
More
15 years 1 week ago #81758 by Tiago Manuel da Costa Silva
Replied by Tiago Manuel da Costa Silva on topic Get article id
So, i have replaced the print button code to link me to a file that makes the pdf. I´m using fpdf.
But i need to get a only some extra fields but using $this->item->extra_fields[1]->name;, how can i make my pdf file use this code?

Please Log in or Create an account to join the conversation.

More
15 years 1 week ago #81759 by AdrianK
Replied by AdrianK on topic Get article id
You need the K2 article-id delivered via GET to your script. You can temporary write the data ($this->items->extra_fields) in a database table and read it in. Or you build a query and more to take it out of the K2 tables. This is not so easy. Or your send the fields data via GET, but then think about security and filter the data.

Please Log in or Create an account to join the conversation.

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar Topic Author
  • Offline
  • Junior Member
More
15 years 1 week ago #81760 by Tiago Manuel da Costa Silva
Replied by Tiago Manuel da Costa Silva on topic Get article id
Temporary write the data ($this->items->extra_fields) in a database table and read it in. How so?

Please Log in or Create an account to join the conversation.

More
15 years 1 week ago #81761 by william white
Replied by william white on topic Get article id
Can you use Yiota's example and try something like this
$yourvar = JRequest::getInt('id');
right where you are in the code and use it on the fly?

Please Log in or Create an account to join the conversation.

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar Topic Author
  • Offline
  • Junior Member
More
15 years 1 week ago #81762 by Tiago Manuel da Costa Silva
Replied by Tiago Manuel da Costa Silva on topic Get article id
I changed the print button code on item.php on the directory \joomla\components\com_k2\templates\default.
Does this answer your question?

Please Log in or Create an account to join the conversation.

  • Tiago Manuel da Costa Silva
  • Tiago Manuel da Costa Silva's Avatar Topic Author
  • Offline
  • Junior Member
More
15 years 1 week ago #81763 by Tiago Manuel da Costa Silva
Replied by Tiago Manuel da Costa Silva on topic Get article id
How can i be able to load and use the k2 classes inside my pdf file (external file)? If i could do this i woudn´t need to use GET or POST and make my website vulnerable

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum