CPMiller Posted June 6, 2011 Share Posted June 6, 2011 What am I missing here... I create a Knowledgebase article. At the top, I create a table of contents (ToC) corresponding to the various sections of the article. I insert an anchor at each subsection title. I then select the text of a ToC entry and click the link icon in the editor menu bar. There's a drop-down list of anchors and I select the appropriate one. The editor fills in the anchor name with the # sign in front in the link URL box. I click Insert. I click Save Changes. I open that article as though I were a customer. I click the ToC entry and instead of going to the anchor in the text, I get kicked back out to the portal entry page. So...what am I missing here? That same page, lifted out of the Knowledgebase article and dumped into DreamWeaver (and from there into a browser) works just fine. Charles 0 Quote Link to comment Share on other sites More sharing options...
scar45 Posted November 17, 2011 Share Posted November 17, 2011 (edited) The same exact thing happens to me, and I am unsure why this behaviour occurs. It seems to be different than the norm/standard. My links are as follows: <a href="#plans">View our plans</a> ... <a id="plans"></a> PLANS Upon clicking the first <a> tag, I get booted back to the main page as well. After looking at the code that is generated, this is what I see: http://dev.xxxxxxxx.com/#plans where I should expect to see something like: http://dev.xxxxxxxx.com/cart.php?gid=2#plans Can any of the devs comment on why this behaviour is occuring? I really need to get this fixed so I can use shortcuts within the same page! ** EDIT ** - OK I believe I found why this is happening, and it is related to the following code in <head>: <base href="http://dev.xxxxxxxx.com/" /> Which will force the browser to use the above as the base URL, effectively breaking the ability to use in-page shortcuts. Does anyone have a solution to this, or is it possible to remove the <base href> tag and still have WHMCS function properly? Thanks in advance for your help... - George Edited November 17, 2011 by scar45 <base href="http://dev.xxxxxxxx.com/" /> 0 Quote Link to comment Share on other sites More sharing options...
scar45 Posted November 17, 2011 Share Posted November 17, 2011 (edited) OK new reply on this one because I've figured out how to fix this with the help of WHMCS' Andrew. To recap, Andrew states the following in regards to the <base href...> tag: "Removing this tag will stop any SEO functionality from working and you would need to alter the image paths etc to load relative from that page." So it is probably not a good idea to remove the <base href...> tag altogether. As a workaround, I had read another article on the web which suggests using JavaScript to simply append the hash'shortcut_id' to a link, however this would require that the user has JS enabled. As all pro web designers out there know, it's best to not require that JS be enabled, but still have your site work properly. Also, I am using jQuery's $.localScroll plugin which allows for animated scrolling with in-page shortcut links. The JS solution above also broke this. My final solution was to use PHP to grab the current page URL (including the query string) and prepend this to the HREF of the shortcut links. Here's what it now looks like, and everything works properly: <a href="{php}echo($_SERVER['REQUEST_URI']);{/php}#plans">View our plans</a> ... <a id="plans"></a> PLANS Note the {php}echo($_SERVER['REQUEST_URI']);{/php} just before the #plans href. This enables the server to render the links using the full path, and doesn't force WHMCS to bump you back to that base URL when you want to use anchor tags in your document for shortcuts. Downside is that the server may have to use 0.000003 more seconds of processing time/CPU due to the extra PHP, but I think it's worth it I hope this helps out anyone else! Edited November 17, 2011 by scar45 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.