How to use url variables in content

Post Reply
altomarketing
Jr. Bludit
Posts: 7
Joined: Sat Jul 10, 2021 4:22 am

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 ? :roll:

Image
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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".
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
altomarketing
Jr. Bludit
Posts: 7
Joined: Sat Jul 10, 2021 4:22 am

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>
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

Which tutorial have you used?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
altomarketing
Jr. Bludit
Posts: 7
Joined: Sat Jul 10, 2021 4:22 am

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 ?
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

What do you want do do? Where is the string enviar-metadata from? Bludit does normally not use such strings.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
altomarketing
Jr. Bludit
Posts: 7
Joined: Sat Jul 10, 2021 4:22 am

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
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
altomarketing
Jr. Bludit
Posts: 7
Joined: Sat Jul 10, 2021 4:22 am

EDI !!! :D :D :D :D :D :D

YOU ROCK !!

SOS LO MAS GRANDE QUE HAY !!!

thanks !!!

It works like charm !!
altomarketing
Jr. Bludit
Posts: 7
Joined: Sat Jul 10, 2021 4:22 am

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>
Post Reply