Welcome Guest, Not a member yet? Register   Sign In
Annoying - Anchor and Template Parser Class combination
#1

[eluser]Y0shi[/eluser]
Hi everyone,

this problem is now annoying me for about 3 hours and I haven't got a solution yet. I'm about to write a menu controller which can also content external / relative links to other sites. When I feed the anchor function with them it put's my base_url() in front.

Code:
<li>&lt;?=anchor('{headelement_link}', '{headelement_name}', array('target' => '{headelement_target}')) ?&gt;</li>


This is a line from my view file I want to parse. I already tried to feed the anchor function directly with the links from my DB and there it perfectly displays the right links. But unfortunately not in the parser class.

Can you think of a solution for my problem?

Many thanks in advance!

Regards,
yoshi
#2

[eluser]Y0shi[/eluser]
doesn't anybody know a starting for a solution? :/

Trying to figure it out myself for quite a while now. Almost thinking Im too dumb Big Grin

Regards
#3

[eluser]InsiteFX[/eluser]
anchor()
Creates a standard HTML anchor link based on your local site URL:

Enjoy
InsiteFX
#4

[eluser]Y0shi[/eluser]
Thanks for the answer, but it doesnt really fit.

My question was: In the placeholders u see in the template part above, internal links like controller links as well as external links like http://www.google.de are generated.

Normally if the anchor function is fed with an external link it leaves the base_url() and just links to the external site. But in my case it puts the base_url in front. Every time... =/

Hope it's now better explained.

Regards
#5

[eluser]Y0shi[/eluser]
Noone got any idea?
#6

[eluser]rogierb[/eluser]
My only guess is that the php gets processed before the varables are parsed.
In that case you would get
Code:
<a href="http://your_local_url{headelement_link}">

To avoid this behaviour, either don't use the anchor method or extend the parser function to read the view file, parse the data, then execute the php.
#7

[eluser]Y0shi[/eluser]
Thanks for the reply.

Are there any tutorials or threads about this u know?
Maybe any already edited classes?

I'm going to search myself too, but if you know some, let me know Wink

Regards Smile
#8

[eluser]rogierb[/eluser]
In the parser->parse() method replace loading of the view file with:

Code:
$CI =& get_instance();
$CI->load->helper('file');
$template = read_file(APPPATH."/views/".$template);

-----
//rest of code
-----

return eval($template);

Untested! So warranty 'til you breath out.
#9

[eluser]Y0shi[/eluser]
tried and modified it. I dont get any result. Just get emptyness where templates should be parsed. =/
#10

[eluser]clip[/eluser]
Have you tried using the anchor function inside the controller instead of doing it in the view?

Edit, forgot to ask if your putting http://www.example.com instead of just www.example.com?

Code:
$head_link = anchor('link_target', 'link_name');

Then in your view:

Code:
<li>{head_link}</li>

I know this is incomplete code but do you get what I am saying?




Theme © iAndrew 2016 - Forum software by © MyBB