Create article with variable is that possible?

General questions relating to Joomla! 1.5 There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
User avatar
lucato
Joomla! Intern
Joomla! Intern
Posts: 99
Joined: Fri Apr 10, 2009 8:13 am
Location: Brazil
Contact:

Create article with variable is that possible?

Postby lucato » Wed Aug 12, 2009 9:53 am

Hi folks, I got a doubt.

Let's suppose I got one article (ID 12) and a link to it like that:
mysite.com/index.php?option=com_content&id=12

I wonder if it would be possible to inform a value in the link and it would be replaced in the article where I've pointed the variables. Let's suposse the link would be something like that:
mysite.com/index.php?option=com_content&id=12&name='Mr. Brow'

So in the article I would have the text like:
bla bla bla bla [name] blabla bla bla bla [name]

and all [name] would be replaced by Mr. Brow that I've informed in the link.

Is there any way to do it? How can I achieve that. A step by step will be appreciated.
Last edited by lucato on Wed Aug 12, 2009 11:16 pm, edited 1 time in total.

User avatar
SlySmiles
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Thu Jul 09, 2009 5:10 pm
Location: Southsea, UK

Re: Create article with variable is that possible?

Postby SlySmiles » Wed Aug 12, 2009 10:30 am

You can do this easily with a content plugin.
There is an howto http://docs.joomla.org/How_to_create_a_content_plugin
In the onPrepareContent function you can search for your {tags}
and replace them with the passed in data using JRequest::get* functions
As you can do so much with the plugins, I can't really go into any details.

User avatar
lucato
Joomla! Intern
Joomla! Intern
Posts: 99
Joined: Fri Apr 10, 2009 8:13 am
Location: Brazil
Contact:

Re: Create article with variable is that possible?

Postby lucato » Wed Aug 12, 2009 3:29 pm

Hi Sly, thanks for your reply. It's a little complicated for me once I'm not good at programming and so on. So, do you know if there is some module, plug-in that I would do it by activing the plug-in and typying the variables directly into the article?

Cheers.
Last edited by lucato on Wed Aug 12, 2009 11:17 pm, edited 1 time in total.

User avatar
SlySmiles
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Thu Jul 09, 2009 5:10 pm
Location: Southsea, UK

Re: Create article with variable is that possible?

Postby SlySmiles » Wed Aug 12, 2009 3:48 pm

I don't know if something exactly like that is already available, but I doubt it.
I can probably knock you something up quickly, but can't guarantee it for security, bugs or anything else...
You'll need some understanding of PHP/CSS/HTML to get to grips with Joomla, as nothing works out of the box quite as expected.
Let me know the basic specs, maybe someone else can give some more insight, if not it shouldn't take long to put something together!

Edit for grammar :)

User avatar
SlySmiles
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Thu Jul 09, 2009 5:10 pm
Location: Southsea, UK

Re: Create article with variable is that possible?

Postby SlySmiles » Wed Aug 12, 2009 4:52 pm

Here's the simple plugin, have a play!
Simply install the plugin and activate it.
Following your example, if you have &name='Mr. Brow' in your URL, you'd now add in your article
{req_replace}name{/req_replace}
Which should then output Mr. Brow

Good luck with it :)
You do not have the required permissions to view the files attached to this post.

User avatar
lucato
Joomla! Intern
Joomla! Intern
Posts: 99
Joined: Fri Apr 10, 2009 8:13 am
Location: Brazil
Contact:

Re: Create article with variable is that possible?

Postby lucato » Wed Aug 12, 2009 8:52 pm

Hey Sly, wow, that seems exactly what I'm looking for, but unfortunately I didn't get to install your plug-in. It is generating the error below:

* XML Parsing Error at 11:194. Error 4: not well-formed (invalid token)
* Plugin Instalar: No plugin file specified

Any idea or new fixed file?

Thanks a lot for your attention.

User avatar
SlySmiles
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Thu Jul 09, 2009 5:10 pm
Location: Southsea, UK

Re: Create article with variable is that possible?

Postby SlySmiles » Wed Aug 12, 2009 10:32 pm

Here's a new one!
I tried adding some more text to the description on the xml, seemed to break it!
I didn't test after adding as I thought : What could go wrong :D
This one should be good....
You do not have the required permissions to view the files attached to this post.

User avatar
lucato
Joomla! Intern
Joomla! Intern
Posts: 99
Joined: Fri Apr 10, 2009 8:13 am
Location: Brazil
Contact:

Re: Create article with variable is that possible?

Postby lucato » Wed Aug 12, 2009 11:11 pm

Wow, amazing! It worked like a charm! Exactly what I needed. I really appreciated that! You need to add it to the Joomla! Extensions database.
Also you can increase the features on it where from the back end we would set more variables throught some input field for var1, var2, var3... and so on, so I would give these variable names like:

var1 = name
var2 = address
var3 = phone
var4 = whatever_name_I_set_for_the_variable

and so on and use the tags in the article:

{req_replace}name{/req_replace}
{req_replace}address{/req_replace}
{req_replace}phone{/req_replace}
{req_replace}whatever_name_I_set_for_the_variable{/req_replace}

Well, just a suggestion.

Sly, if you add it and need my review, you can count on me. Thanks a lot for your time and effort. I really appreciated that.

If you're a designer/webdesigner or other and need high-resolution images for your projects I can provide you 10 FREE CREDITS to download them once you're not an iStockphoto member yet: http://[no tiny url]/13S99F
Ask me this gift before signing-up if you want to.

Thanks once again for your attention and have a nice week.

User avatar
SlySmiles
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Thu Jul 09, 2009 5:10 pm
Location: Southsea, UK

Re: Create article with variable is that possible?

Postby SlySmiles » Wed Aug 12, 2009 11:22 pm

lucato wrote:var1 = name
var2 = address
var3 = phone
var4 = whatever_name_I_set_for_the_variable

and so on and use the tags in the article:

{req_replace}name{/req_replace}
{req_replace}address{/req_replace}
{req_replace}phone{/req_replace}
{req_replace}whatever_name_I_set_for_the_variable{/req_replace}


I'm not quite sure what you mean by adding an indirection,as it reads from the URL, so if you've got &name='My Name'&address='MyAddress' etc it will all just work. It's a very simple plugin, so easy to modify :)
I don't know how to add it to the extensions database :| It seems so simple it's hardly worth it!

It didn't take long to put together, glad it's helped you :D

User avatar
lucato
Joomla! Intern
Joomla! Intern
Posts: 99
Joined: Fri Apr 10, 2009 8:13 am
Location: Brazil
Contact:

Re: Create article with variable is that possible?

Postby lucato » Thu Aug 13, 2009 11:01 am

SlySmiles wrote:I don't know how to add it to the extensions database :| It seems so simple it's hardly worth it!
It didn't take long to put together, glad it's helped you :D

- I think you can help the community by posting into the extensions database. Here are some info for it that I've found. I hope that helps:
http://docs.joomla.org/Joomla!_Extensio ... ns_site.3F
http://extensions.joomla.org/rules

SlySmiles wrote:I'm not quite sure what you mean by adding an indirection,as it reads from the URL, so if you've got &name='My Name'&address='MyAddress' etc it will all just work. It's a very simple plugin, so easy to modify :)

- I see, it do more than I tought. I tought I just got to set one variable, but it is more amazing, I can set a lot of variables and add in the URL link. So, as your example I got to set &name=,&lastname=,&phone=,&whateverIwant=, :0) Really great!!!

Sly, I just still have one big doubt, and I don't know if you can help me also on this one. In my language I use some special characters such as ç, á, é, ã, and etc, but If I type the text this way in the URL, it gives an error in the page. Do you know where I can a find a list with the codes that would be replaced by these. Like, I know that %20 is equal to spacebar, but what codes may I use for these special characters. Do you have any idea/list?

Thank again and have a nice day.

User avatar
SlySmiles
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Thu Jul 09, 2009 5:10 pm
Location: Southsea, UK

Re: Create article with variable is that possible?

Postby SlySmiles » Thu Aug 13, 2009 11:52 am

I'm not sure about the details, but I believe there you can 'escape' the characters, see http://www.blooberry.com/indexdot/html/ ... coding.htm
I don't know joomla enough to find out to encode/decode these, or if JRequest deals with them internally. It's not a problem I've yet had to face.
I'd suggest a new post asking about this specific, and I suppose it will be just 1 extra line of code to make the plugin work correctly if it doesn't already.

User avatar
lucato
Joomla! Intern
Joomla! Intern
Posts: 99
Joined: Fri Apr 10, 2009 8:13 am
Location: Brazil
Contact:

Re: Create article with variable is that possible?

Postby lucato » Thu Aug 13, 2009 12:35 pm

Yup, none codes below are working in the URL:
ã
%E3
&#227;
&atilde;

I think you're right, it will need a extra code line. I'll try to post a new thread.
Thanks a lot for your time and don't forget, if you need those free credits to buy an image to print ang hang in your wall, use in your projects or so on, just let me know. ;0)

Best wishes,
Lucato

User avatar
SlySmiles
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Thu Jul 09, 2009 5:10 pm
Location: Southsea, UK

Re: Create article with variable is that possible?

Postby SlySmiles » Thu Aug 13, 2009 12:50 pm

If you get an answer, let just send me a PM or email, and I can update the plugin. I've added it to my site, and at some point will submit it to the extension directory.
Thanks for the offer for the free credits :D

User avatar
lucato
Joomla! Intern
Joomla! Intern
Posts: 99
Joined: Fri Apr 10, 2009 8:13 am
Location: Brazil
Contact:

Re: Create article with variable is that possible?

Postby lucato » Thu Aug 13, 2009 12:59 pm

You're welcome. Thank you.
I'll let you know if I get some feedback. You can follow this new thread too:
viewtopic.php?f=428&t=430193

Cheers,
Lucato

albus1234
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Feb 15, 2011 9:26 am

Re: Create article with variable is that possible?

Postby albus1234 » Wed Feb 16, 2011 7:01 am

Hello Sly,

Since you have created this plugin so I am directly asking you for help.
Your creation is simply amazing and it helped me so far without any issues..but there is an additional help that I am asking for.
Could you tell me a way by which I could use this for changing or adding meta-tags through URL ?
Since Joomla maintains its own way to manage title or meta keywords, I cannot use your plugin to change them. So is there a way around or another plugin with which I can change the metas with still using your plugin?

P.S. - I am a newbie in Joomla and also in coding stuffs.


Thanks in Advance
Albus.

User avatar
SlySmiles
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Thu Jul 09, 2009 5:10 pm
Location: Southsea, UK

Re: Create article with variable is that possible?

Postby SlySmiles » Wed Feb 16, 2011 5:39 pm

albus1234 wrote:Hello Sly,

Could you tell me a way by which I could use this for changing or adding meta-tags through URL ?
Since Joomla maintains its own way to manage title or meta keywords, I cannot use your plugin to change them. So is there a way around or another plugin with which I can change the metas with still using your plugin?
Albus.


I don't think this plugin will be able to handle meta tags as they are handled in the <head> part of the html and are already parsed when this plugin is called. The title is also handled the same way.

You'd need to look for a plugin that can handle the data in the <head> section and replace the plugin code from mine into there. the code itself is very simple so should pose a problem.

btw glad the plugin has helped you.

salem1
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Aug 29, 2011 5:05 pm

Re: Create article with variable is that possible?

Postby salem1 » Mon Aug 29, 2011 5:14 pm

SlySmiles wrote:Here's a new one!
I tried adding some more text to the description on the xml, seemed to break it!
I didn't test after adding as I thought : What could go wrong :D
This one should be good....


Just a quick post to say, thank you very much. This was just what I was after too. Glad to see that it strips tags too.

smartedy
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Apr 08, 2016 3:17 pm

Re: Create article with variable is that possible?

Postby smartedy » Sat Apr 09, 2016 3:15 am

SlySmiles wrote:Here's a new one!
I tried adding some more text to the description on the xml, seemed to break it!
I didn't test after adding as I thought : What could go wrong :D
This one should be good....


Hi!! im new to joomla, new to php, new to the forum... i downloaded your plugin and it did not installed because im using joomla 3.5... so it began my journey to port it from 1.5 to 3.5......

aaaaannnnddd i couldnt....

edited the xml
edited the php with the changes that are documented here:

https://docs.joomla.org/J2.5:Adapting_a ... Joomla_2.5

but im still too new to this...

any help? i need this working to then use it to alter Databases (another journey will begin!)

thanks in advance.

i'll keep reading!

edit: i would have uploaded the files modified, but it may cause confusion and i see no point in uploading "useless" files.


Return to “General Questions/New to Joomla! 1.5”

Who is online

Users browsing this forum: No registered users and 9 guests