Page 1 of 1
How to use url variables in content
Posted: Sat Jul 10, 2021 4:32 am
by altomarketing
Hello ! i have a question, i would like to print url variables inside a post like $get or something.. how can i do it ?
I know now that i can use
echo $url->parameter('user'); but it prints in all the pages , not content.
I need to use this variables by editing posts with several variables inside the post, how can i do it ?
Re: How to use url variables in content
Posted: Sat Jul 10, 2021 7:51 pm
by Edi
altomarketing wrote: ↑Sat Jul 10, 2021 4:32 am
I need to use this variables by editing posts with several variables inside the post, how can i do it ? :
Use JavaScript. You can find several tutorials with a search for "get url parameters javascript".
Re: How to use url variables in content
Posted: Sat Jul 10, 2021 10:40 pm
by altomarketing
This does not work in post in bluidit
what im missing ?
Code: Select all
<script language="javascript" type="text/javascript">
$.urlParameters = function(params) {
var results = new RegExp("[?&]" + params + "=([^&#]*)").exec(
window.location.href
);
return results ? decodeURI(results[1]) : null;
};
document.write("variable uno is ", $.urlParameters("variable1"));
document.write(", ", $.urlParameters("variable2"));
</script>
</p>
Re: How to use url variables in content
Posted: Sat Jul 10, 2021 10:54 pm
by Edi
Which tutorial have you used?
Re: How to use url variables in content
Posted: Tue Jul 13, 2021 3:57 am
by altomarketing
Edi wrote: ↑Sat Jul 10, 2021 10:54 pm
Which tutorial have you used?
I tested this three >
https://www.codegrepper.com/code-exampl ... ing+jquery
None works inside the post, do you have any example to help me ?
Re: How to use url variables in content
Posted: Fri Jul 16, 2021 10:36 pm
by Edi
What do you want do do? Where is the string enviar-metadata from? Bludit does normally not use such strings.
Re: How to use url variables in content
Posted: Fri Jul 16, 2021 10:42 pm
by altomarketing
metadata is an fiendly url example .
See my first post (image), i want to use url variables to write it inside the post.
Live Example :
http://serviciostreaming.com/manual/pru ... =joseperez
I want to post Hola joseperez , insted of Hola %user
Re: How to use url variables in content
Posted: Sat Jul 17, 2021 1:20 pm
by Edi
You can use something like this:
Code: Select all
<script>
url = window.location.href;
str = url.indexOf("user");
name = url.slice(str+5);
document.write(name);
</script>
For the ouput see also:
https://www.w3schools.com/js/js_output.asp
Re: How to use url variables in content
Posted: Mon Jul 19, 2021 3:53 am
by altomarketing
EDI !!!
YOU ROCK !!
SOS LO MAS GRANDE QUE HAY !!!
thanks !!!
It works like charm !!
Re: How to use url variables in content
Posted: Mon Jul 19, 2021 5:20 am
by altomarketing
Just for record, after i learn.
This solution is compatible with multiples variables in url:
Code: Select all
<script>
url = window.location.href;
dato1 = url.split( 'user=' )[1];
dato2 = dato1.split( '&' )[0];
document.write(dato2);
</script>