yggdrasil Posted February 5, 2016 Share Posted February 5, 2016 Well, the forum does not let post on old topics. My question is regarding this topic, so maybe you should read that first : http://forum.whmcs.com/showthread.php?29124-How-do-I-show-the-active-page-in-my-navigation What about the pages that have no action on them? One example is that you can use the filename variable for the logout page but not for the login page. It seems WHMCS is not using file names for every page and sadly they are not using actions either. For example if you load login.php it redirects to clientarea.php So there are pages like the login page where you can't use the file name, and neither the title of the page (since its just show the Client Area page title). I tried to see if Smarty supported the URI to match the full ending url but that didn't work either. What would be the solution to show content without file name or page title and still be able to identify the page the user is on? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2016 Share Posted February 6, 2016 they'd be a few ways to do it, but the simplest would be to detect any Smarty variables that are unique to the template - so taking your login page as an example, the following variables will exist... $formaction -> "dologin.php" $loginpage -> "true" $templatefile -> "login" if the page is using a unique template, then $templatefile will be useful... 0 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted February 6, 2016 Author Share Posted February 6, 2016 they'd be a few ways to do it, but the simplest would be to detect any Smarty variables that are unique to the template - so taking your login page as an example, the following variables will exist... $formaction -> "dologin.php" $loginpage -> "true" $templatefile -> "login" if the page is using a unique template, then $templatefile will be useful... Isn't there a URI server with Smarty to maybe detect the url? The problem seems that WHMCS templates not really consistent anymore in this regards. Some files are template files on its own, but are not actually used but instead embed into another file. Example, the dologin.php file seems to be used by the clientarea template. There should be a more simple way without that much overhead of detecting specific variables or code in a page. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted February 6, 2016 Share Posted February 6, 2016 dealing with complete URL will be more complicated, if $templatefile = login.tpl then you know what the user currently viewing, but with complete URL it will be http://yourwebsite.com/clientarea.php this could be the client area home page or login screen. so as brian already suggested you can use $templatefile to detect the page being viewed, and $loggedin to detect client status if logged-in or not. 0 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted February 6, 2016 Author Share Posted February 6, 2016 dealing with complete URL will be more complicated, if $templatefile = login.tpl then you know what the user currently viewing, but with complete URL it will be http://yourwebsite.com/clientarea.php this could be the client area home page or login screen. so as brian already suggested you can use $templatefile to detect the page being viewed, and $loggedin to detect client status if logged-in or not. I don't need to detect the user but show specific content on the login page header as well other pages. I managed to do this with template file and the action request for most pages but that approach does not work for all templates. The templatefile variable does not work, I tried that before posting this, both with login.php or dologin.php The reason is that when you load the login template it actually loads the clientarea page. Template file works fine for example with the logout template but not with the login page. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2016 Share Posted February 6, 2016 let's say we change the following line in header.tpl... <title>{if $kbarticle.title}{$kbarticle.title} - {/if}{if $loginpage eq 'true'}{$LANG.login}{else}{$pagetitle}{/if} - {$companyname}</title> on most pages, it will show $pagetitle, but if trying to login (clientarea.php, login php, dologin.php etc), it will show "Login" in the title... even on clientarea.php it will show $pagetitle, UNLESS you're trying to log in. without knowing exactly what you want to do, it's difficult to help - but you should be able to do it with Smarty. 0 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted February 6, 2016 Author Share Posted February 6, 2016 let's say we change the following line in header.tpl... <title>{if $kbarticle.title}{$kbarticle.title} - {/if}{if $loginpage eq 'true'}{$LANG.login}{else}{$pagetitle}{/if} - {$companyname}</title> on most pages, it will show $pagetitle, but if trying to login (clientarea.php, login php, dologin.php etc), it will show "Login" in the title... even on clientarea.php it will show $pagetitle, UNLESS you're trying to log in. without knowing exactly what you want to do, it's difficult to help - but you should be able to do it with Smarty. What I want to do is style a bit the titles which I did in the /includes/pageheader.tpl pageheader.tpl is the one showing the titles on templates. I used here both: if $filename eq "clientarea" and $smarty.get.action eq "domains" Now we can target the domains page. Or if $filename eq logout We can target the page when a users hits the log out button. Where do you see the Login title in the page? I don't. When you go the login page directly by typing login.php it shows the Client Area title and page because it redirects to that page. Same when you try to log in for example it goes to: clientarea.php?incorrect=true There is no Login title on this page, so you cannot use the title here. And you cannot use $filename either because the login page actually loads the clientarea.php, not the login.php or dologin.php (both of them) redirect to clientarea.php All I want is to add a bit of code next to the pages titles. You could pull out some fancy trick trying to detect the code on the login page but if I need to add code to all of the templates, not just login. And doing this for every page seems like a a mess. For my luck most pages inside the customer area use the action trigger and some templates are on their own file which makes it easier. But WHMCS just decide to use the clientarea.php for allot of stuff which was in the past on its own templates. - - - Updated - - - I seems I hit the submit button to fast. Indeed, your code does work: {if $loginpage eq 'true'} I really appreciate that. Thank you! I wonder if this code works on all templates. If yes, I'm not sure why other people here in the forums suggest more complicated variables like the one I posted above which uses the filename or detecting the action on a page. It seems detecting the template page is easier and faster. Or maybe I do have to use the mixed approaches for different pages. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 7, 2016 Share Posted February 7, 2016 It seems detecting the template page is easier and faster. Or maybe I do have to use the mixed approaches for different pages. I think you may have to use different approaches depending upon what's available to you. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.