FAQ
I am trying to send an email from CakePHP 2.1.2 via console shell
(eventually by a cron job). The view I am sending is a calendar with links
back to the applications web page. The problem I am finding is that the
urls do not include the correct path and from what I have read it is
because there is no request object since I am using the console. For
example, if I create the view in my browser I get links like this:


http://localhost/ReportMonitor/scheduledReports/index/show_date:2012-06-10/result:GOOD

but in the email using the same code I get this:

http://localhost/scheduledReports/index/show_date:2012-06-10/result:GOOD

which is close, but no cigar.

I have been trying to find the global that I can set somewhere to just hard
code the app subdirectory but haven't found anything that works yet. The
links are made by a code like this:

$newUrl = array();
$newUrl['controller'] = 'scheduledReports';
$newUrl['action'] = 'index';
$newUrl['url'] = array();

foreach ($data as $key => $value) {
$newUrl['show_date'] = "$year-$month-$key";
$newUrl['result'] = 'GOOD';
$data[$key]['num_complete'] = $this->Html->link(__('Complete: ') .
$value['num_complete'], Router::reverse($newUrl, true), array('class' =>
'green'));

I would think this is a common function (sending valid urls in console
generated email) but I just can't figure it out.

Thanks

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at http://groups.google.com/group/cake-php

Search Discussions

  • AD7six at Jun 22, 2012 at 4:08 pm

    On Friday, 22 June 2012 17:44:27 UTC+2, Matt wrote:
    I am trying to send an email from CakePHP 2.1.2 via console shell
    (eventually by a cron job). The view I am sending is a calendar with links
    back to the applications web page. The problem I am finding is that the
    urls do not include the correct path and from what I have read it is
    because there is no request object since I am using the console. For
    example, if I create the view in my browser I get links like this:


    http://localhost/ReportMonitor/scheduledReports/index/show_date:2012-06-10/result:GOOD

    but in the email using the same code I get this:


    http://localhost/scheduledReports/index/show_date:2012-06-10/result:GOOD

    which is close, but no cigar.

    I have been trying to find the global that I can set somewhere

    Since the cli doen't know what domain it's on, that's the right thing to do.

    define('FULL_BASE_URL', "http://mydomain.com/subfolder");

    Will allow you to generate urls on the cli.

    AD

    --
    Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
    Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


    To unsubscribe from this group, send email to
    [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
  • Matt at Jun 22, 2012 at 7:39 pm
    That's the direction I was thinking, but adding that code causes an error
    about it already being defined. I echoed the current value and it is
    http://localhost as expected. I'm assuming it gets set in the console
    startup so I don't think I can redefine it.

    Thanks
    On Friday, June 22, 2012 11:08:51 AM UTC-5, AD7six wrote:


    On Friday, 22 June 2012 17:44:27 UTC+2, Matt wrote:

    I am trying to send an email from CakePHP 2.1.2 via console shell
    (eventually by a cron job). The view I am sending is a calendar with links
    back to the applications web page. The problem I am finding is that the
    urls do not include the correct path and from what I have read it is
    because there is no request object since I am using the console. For
    example, if I create the view in my browser I get links like this:


    http://localhost/ReportMonitor/scheduledReports/index/show_date:2012-06-10/result:GOOD

    but in the email using the same code I get this:


    http://localhost/scheduledReports/index/show_date:2012-06-10/result:GOOD

    which is close, but no cigar.

    I have been trying to find the global that I can set somewhere

    Since the cli doen't know what domain it's on, that's the right thing to
    do.

    define('FULL_BASE_URL', "http://mydomain.com/subfolder");

    Will allow you to generate urls on the cli.

    AD
    --
    Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
    Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


    To unsubscribe from this group, send email to
    [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
  • Matt at Jun 22, 2012 at 7:51 pm
    Aha, I figured it out! I had to hack the ShellDispatcher.php to change the
    define statement This works if I just have one shell, but if I add others
    I'll just have to create another global to use instead of having it
    hardcoded. Actually, that might be a good idea for adding to the core
    code.

    if (!defined('FULL_BASE_URL')) {
    define('FULL_BASE_URL', 'http://localhost/ReportMonitor');
    }

    Thanks!
    On Friday, June 22, 2012 11:08:51 AM UTC-5, AD7six wrote:


    On Friday, 22 June 2012 17:44:27 UTC+2, Matt wrote:

    I am trying to send an email from CakePHP 2.1.2 via console shell
    (eventually by a cron job). The view I am sending is a calendar with links
    back to the applications web page. The problem I am finding is that the
    urls do not include the correct path and from what I have read it is
    because there is no request object since I am using the console. For
    example, if I create the view in my browser I get links like this:


    http://localhost/ReportMonitor/scheduledReports/index/show_date:2012-06-10/result:GOOD

    but in the email using the same code I get this:


    http://localhost/scheduledReports/index/show_date:2012-06-10/result:GOOD

    which is close, but no cigar.

    I have been trying to find the global that I can set somewhere

    Since the cli doen't know what domain it's on, that's the right thing to
    do.

    define('FULL_BASE_URL', "http://mydomain.com/subfolder");

    Will allow you to generate urls on the cli.

    AD
    --
    Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
    Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


    To unsubscribe from this group, send email to
    [email protected] For more options, visit this group at http://groups.google.com/group/cake-php

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcake-php @
categoriesphp
postedJun 22, '12 at 3:44p
activeJun 22, '12 at 7:51p
posts4
users2
websitecakephp.org
irc#cakephp

2 users in discussion

Matt: 3 posts AD7six: 1 post

People

Translate

site design / logo © 2023 Grokbase