Passing variables between URL
-
- New Member
- Posts: 8
- Joined: Fri Mar 06, 2009 12:28 pm
Passing variables between URL
Hello,
I am farely new to programming and very new to CMSMS so go easy on me! I have my own code which I have integrated into templates using the {php} tags. This code works fine when it is not in CMSMS. It is for my intranet at work. I have created 2 pages - staff and staffDetails and I am trying to pass a variable between the staff page and staffDetails page. The staff page contains the employees and there is a link next to each name to view more information. This usually pulls the staffID from the database and the persons details are displayed. I have created staffDetails with staff as its parent. Here is the code I have used:
Staff Page
This to display list of people with a 'more' link next to every name.
{php}
while ($row = $resultSystems -> fetch_assoc()) {
{/php}
{php}
echo $row['name'];
echo ' More'; {/php}
{php} } {/php}
When I hover over the more link in a browser the correct staffID number is displayed but when I click on it it says Page can not be displayed. Hope this is clear enough.
Thanks,
Glenn
I am farely new to programming and very new to CMSMS so go easy on me! I have my own code which I have integrated into templates using the {php} tags. This code works fine when it is not in CMSMS. It is for my intranet at work. I have created 2 pages - staff and staffDetails and I am trying to pass a variable between the staff page and staffDetails page. The staff page contains the employees and there is a link next to each name to view more information. This usually pulls the staffID from the database and the persons details are displayed. I have created staffDetails with staff as its parent. Here is the code I have used:
Staff Page
This to display list of people with a 'more' link next to every name.
{php}
while ($row = $resultSystems -> fetch_assoc()) {
{/php}
{php}
echo $row['name'];
echo ' More'; {/php}
{php} } {/php}
When I hover over the more link in a browser the correct staffID number is displayed but when I click on it it says Page can not be displayed. Hope this is clear enough.
Thanks,
Glenn
Re: Passing variables between URL
Hi.
Where are you actually inserting this bit of code?
You said the template. If that is the case, you should not use bb code. You should instead use proper php tags, such as
rather than {php} etc..
The method you are showing is only used if you insert php calls into a page you are creating in admin.
Where are you actually inserting this bit of code?
You said the template. If that is the case, you should not use bb code. You should instead use proper php tags, such as
Code: Select all
<?php while ($row = $resultSystems -> fetch_assoc()) { ?>
The method you are showing is only used if you insert php calls into a page you are creating in admin.
-
- New Member
- Posts: 8
- Joined: Fri Mar 06, 2009 12:28 pm
Re: Passing variables between URL
Hi, I have just tried a simple code test in the template:
and it doesnt work. Unless I havent changed a setting or something? Yes I am inserting it into the template. The strange thing is that the code to bring the list of employees works, it is when I am trying to pass the variable when I get 'page cannot be displayed'.
Thanks
and it doesnt work. Unless I havent changed a setting or something? Yes I am inserting it into the template. The strange thing is that the code to bring the list of employees works, it is when I am trying to pass the variable when I get 'page cannot be displayed'.
Thanks
Re: Passing variables between URL
See config.php line 116: $config['use_smarty_php_tags'] = false;
Set this to true and you can use php-Code within your template using {php} ... {/php}.
Or create an UDT where you can just write php-Code (without '').
In your template you can call this UDT with just {your_tag_name}.
Set this to true and you can use php-Code within your template using {php} ... {/php}.
Or create an UDT where you can just write php-Code (without '').
In your template you can call this UDT with just {your_tag_name}.
-
- New Member
- Posts: 8
- Joined: Fri Mar 06, 2009 12:28 pm
Re: Passing variables between URL
Yes i do have use smarty tags set to true. my only problem is passing the variable in the URL. I can pull the info from the database fine, but when i try to view any details of the info it doesnt work.
Re: Passing variables between URL
Im no prefessional programmer, but just some ideas:
It seems to be that you use the internal pretty-urls, don't you?
So i believe that because of the internal url-rewriting of CMSms core the CMS searches for a page called "staffDetails?staffID=X".
That means the system wants to load "index.php?page=staffDetails?staffID=X"
And this is no valid page alias.
Just watch your URL.glennjamieson wrote:
echo ' More'; {/php}
It seems to be that you use the internal pretty-urls, don't you?
So i believe that because of the internal url-rewriting of CMSms core the CMS searches for a page called "staffDetails?staffID=X".
That means the system wants to load "index.php?page=staffDetails?staffID=X"
And this is no valid page alias.
Last edited by NaN on Sun Mar 08, 2009 10:20 pm, edited 1 time in total.
-
- New Member
- Posts: 8
- Joined: Fri Mar 06, 2009 12:28 pm
Re: Passing variables between URL
yes you are correct. I have now set pretty urls to false but this hasnt worked. i think i know what you are saying, and it sounds correct. what you are saying is right but is there a way to do what i need to do?
thanks again
thanks again
Re: Passing variables between URL
My advice:
1. not use php in template but build an UDT for retrieve data from DB (look examples in "share UDT" in wiki)
2. if you have some skills, use CMSMS API for URL generating or use un direct url (index.php?page=alias_of_target&myvar=myval)
3. for retrieve your data in template of target page use the variable {$smarty.get.myvar} (ex: $smarty.get.staffID)
Alby
1. not use php in template but build an UDT for retrieve data from DB (look examples in "share UDT" in wiki)
2. if you have some skills, use CMSMS API for URL generating or use un direct url (index.php?page=alias_of_target&myvar=myval)
3. for retrieve your data in template of target page use the variable {$smarty.get.myvar} (ex: $smarty.get.staffID)
Alby
Last edited by alby on Sun Mar 08, 2009 10:36 pm, edited 1 time in total.
-
- New Member
- Posts: 8
- Joined: Fri Mar 06, 2009 12:28 pm
Re: Passing variables between URL
hello. the third option sounds like something i can do. can you please give me more detail of how to do this?
thanks
thanks
Re: Passing variables between URL
http://www.smarty.net/manual/en/languag ... smarty.phpglennjamieson wrote: hello. the third option sounds like something i can do. can you please give me more detail of how to do this?
you can display all GET variables in smarty with {$smarty.get.myvar}
Alby
-
- New Member
- Posts: 8
- Joined: Fri Mar 06, 2009 12:28 pm
Re: Passing variables between URL
Re: you can display all GET variables in smarty with {$smarty.get.myvar}
where exactly do I put this code? in the actual link?
where exactly do I put this code? in the actual link?
Re: Passing variables between URL
This is for target page (I think your StaffDetail):glennjamieson wrote: where exactly do I put this code? in the actual link?
For Staff page and link follow:alby wrote: 3. for retrieve your data in template of target page use the variable {$smarty.get.myvar} (ex: $smarty.get.staffID)
Albyalby wrote: 2. if you have some skills, use CMSMS API for URL generating or use un direct url (index.php?page=alias_of_target&myvar=myval)
-
- New Member
- Posts: 8
- Joined: Fri Mar 06, 2009 12:28 pm
Re: Passing variables between URL
hey alby,
I am sure what you are saying is correct but I cant figure out how to do it. it is very frustrating. is there no simple way to pass a variable in cmsms? what i am trying to do should be quite easy.
I am sure what you are saying is correct but I cant figure out how to do it. it is very frustrating. is there no simple way to pass a variable in cmsms? what i am trying to do should be quite easy.
Re: Passing variables between URL
Check the sintax of your linkglennjamieson wrote: I am sure what you are saying is correct but I cant figure out how to do it. it is very frustrating. is there no simple way to pass a variable in cmsms? what i am trying to do should be quite easy.
Is it correct? Or maybe: Moreglennjamieson wrote: echo ' More'; {/php}
Alby