Monday, January 25, 2010

Re: creating absolute links (including site)

simply with an include specifying a remote URL; of course the web server
should be set to allow that

cheers
Lorenzo

euromark wrote:
> sure
> that would be a scenario where you'd use it
>
> how do you include a foreign page via php?
> usually this is not permitted from the file system / php
>
> or do you mean like an iframe / widget?
>
>
>
> On 25 Jan., 17:23, Lorenzo Bettini <bett...@dsi.unifi.it> wrote:
>> yes, exactly only for some urls: say that a page with urls is thought to
>> be php included on another external site, then the links in the included
>> page need to be absolute otherwise they would refer to the including
>> site and they would be dead links.
>>
>> cheers
>> Lorenzo
>>
>>
>>
>> euromark wrote:
>>> exactly
>>> but what is the point of creating all urls full?
>>> usually you only do that with urls that are sent in emails or pointed
>>> out to bookmark on the website...
>>> all other links can stay relative to root...
>>> i didnt understand you right away
>>> i thought you needed to do that only for some urls, not for all!
>>> On 25 Jan., 12:57, Lorenzo Bettini <bett...@dsi.unifi.it> wrote:
>>>> That's exactly what I meant, and I think it was John's point when he
>>>> answered my very first question.
>>>> So if I use link together with url (and true of course) everything
>>>> should work out fine, that's what you mean right? Even for non root
>>>> sites, right?
>>>> cheers
>>>> Lorenzo
>>>> euromark wrote:
>>>>> oh yes
>>>>> thats of course a possiblity too
>>>>> using "true" as second param of Html->url()
>>>>> this way you have already "http://.." which doesnt break Html->link()
>>>>> sry - you're right
>>>>> just dont forget the "true" :) than everything's fine
>>>>> On 24 Jan., 17:06, Lorenzo Bettini <bett...@dsi.unifi.it> wrote:
>>>>>> I'm already using link in connection with url (specifying true), but I
>>>>>> thought you had said that this might not work sometime...
>>>>>> and I don't want to set a constant for the host base, that's why I was
>>>>>> using url() with true, which seems to work fine...
>>>>>> euromark wrote:
>>>>>>> try this:
>>>>>>> $this->Html->link(HTTP_BASE.$this->Html->url(array
>>>>>>> ('action'=>'...', ...)));
>>>>>>> (1.3 syntax)
>>>>>>> whereas HTTP_BASE should be yourhttp://domain.de
>>>>>>> i have this in my bootstrap:
>>>>>>> define('HTTP_HOST',env('HTTP_HOST'));
>>>>>>> define('HTTP_BASE','http://'.HTTP_HOST);
>>>>>>> On 24 Jan., 12:06, Lorenzo Bettini <bett...@dsi.unifi.it> wrote:
>>>>>>>> sorry if I come back on this issue, but this use of link method in the
>>>>>>>> html helper does not seem to be documented: the book reports this method
>>>>>>>> signature:
>>>>>>>> link(string $title, mixed $url = null, array $htmlAttributes = array(),
>>>>>>>> string $confirmMessage = false, boolean $escapeTitle = true)
>>>>>>>> euromark wrote:
>>>>>>>>> actually its even way easiert!
>>>>>>>>> $html->link($url, TRUE)
>>>>>>>>> does the trick
>>>>>>>>> the above solution from john might even be wrong in some cases
>>>>>>>>> (if you're not at the top level of your domain, it adds the folders to
>>>>>>>>> the webroot twice...)
>>>>>>>>> On 29 Dez., 12:00, Lorenzo Bettini <bett...@dsi.unifi.it> wrote:
>>>>>>>>>> Hey thanks, that's exactly what I needed!
>>>>>>>>>> I had searched for it in the HtmlHelper but I hadn't found it since it's
>>>>>>>>>> an inherited method :)
>>>>>>>>>> cheers
>>>>>>>>>> Lorenzo
>>>>>>>>>> John Andersen wrote:
>>>>>>>>>>> Use the html helpers url method to create the full url for the html
>>>>>>>>>>> helpers link method, as:
>>>>>>>>>>> echo $html->link('TEST LINK', $html->url('/advances/forward', true));
>>>>>>>>>>> Enjoy,
>>>>>>>>>>> John
>>>>>>>>>>> On Dec 29, 11:07 am, Lorenzo Bettini <bett...@dsi.unifi.it> wrote:
>>>>>>>>>>>> Hi
>>>>>>>>>>>> with the Html and Form helper it's already easy to create absolute links
>>>>>>>>>>>> (starting from the root of the site), but I'd need to create links that
>>>>>>>>>>>> also include the address of the site (starting with http://).
>>>>>>>>>>>> This is needed since the output of the cakephp site should also be
>>>>>>>>>>>> included in other sites (with different addresses).
>>>>>>>>>>>> Is there an automatic way to do this? Or, I guess, I should set the
>>>>>>>>>>>> site name in some configuration file myself?
>>>>>>>>>>>> thanks in advance
>>>>>>>>>>>> Lorenzo
>>>>>> --
>> --

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: