(7) Urls Controlling :-
we will talk about :-
(1) Url_for() function.
(3) Use Url_for() example.
In the route.ring we have this code
In the website/testurls.ring we have this code :
In the website/testurls2.ring we have this code :
In the website/templates/testurls.html we have this code
In the website/templates/testurls2.html we have this code
we will talk about :-
- Url_for() function.
- MainUrl Variable.
- Use Url_for() example.
(1) Url_for() function.
Url_for(cRoute_Name)
this function take one parameter as a string (Not the full url just the route name ...).
The defult Value for this Variable is (http://localhost/)
Note:-When you set this variable end it with back slash ('/') like in this example
(3) Use Url_for() example.
In the route.ring we have this code
#!ring -cgi load 'dragon-ring.ring' import system.Web MainUrl = 'http://192.168.0.108/' app.route('testurls',:ringfile,"testurls.ring") app.route('testurls2',:ringfile,"testurls2.ring")
In the website/testurls.ring we have this code :
import system.web
dring{
html(template('testurls.html',self))
}
In the website/testurls2.ring we have this code :
import system.web
dring{
html(template('testurls2.html',self))
}
In the website/templates/testurls.html we have this code
<div class='justify-content-center'>
<a class="btn btn-primary" href="{%=url_for('TestUrls2')%}">Go to TestUrls2 Page</a>
</div>
In the website/templates/testurls2.html we have this code
<div class='justify-content-center'>
<a class="btn btn-primary" href="{%=url_for('TestUrls')%}">Go to TestUrls Page</a>
</div>
Note:- You can set one MainUrl (one domain name)
Note:-You have to Set the value of MainUrl Variable in the top of route.ring file
I hope it was easy for you ...