How do I add the site name to my theme?
Permalink 2 users found helpful
I know how to do it in previous versions, but that doesn't work in 5.7 so how do I do it now?
Dashboard > system&settings > site name
Thanks, but that's not what I meant. I meant adding it to my theme in code.
Like in previous versions of Concrete5 I could do this:
But if I do that now I get an error, so I guess it works differently now.
Like in previous versions of Concrete5 I could do this:
<?php $block = Block::getByName('My_Site_Name'); if( $block && $block->bID ) $block->display(); else echo SITE; ?>
But if I do that now I get an error, so I guess it works differently now.
$site = Config::get('concrete.site'); echo $site;
If I put this into my view.php, it works, I get the site name.
If I put this into my block controller.php, it throws a "syntax error, unexpected '(', expecting ',' or ';' "
How come?
How can I get the Site Name in the controller?
Thanks.
If I put this into my block controller.php, it throws a "syntax error, unexpected '(', expecting ',' or ';' "
How come?
How can I get the Site Name in the controller?
Thanks.
Can you copy-paste that line in your code plus 3 lines before and 3 lines after it?
Syntax error means that you wrote something that is completely invalid to the parser, so you probably misplaced some character.
Syntax error means that you wrote something that is completely invalid to the parser, so you probably misplaced some character.
If I do this:
everything's fine.
If I do this:
I've got that error.
If I put
in the view.php, it shows the site name alright.
public $email_to = ''; public $site_name = ''; public $email_subject = 'Question from site %s'; public $wait_time = 60; public function add() { $this->createTable(); }
If I do this:
public $email_to = ''; public $site_name = Config::get('concrete.site'); public $email_subject = 'Question from site %s'; public $wait_time = 60; public function add() { $this->createTable(); }
If I put
$site = Config::get('concrete.site'); echo $site;
Ah yes, you get that error, because that line is not allowed there. Only static stuff like a string or a number is allowed there, not dynamic stuff like function calls. Change it to this:
public $email_to = ''; public $site_name; public $email_subject = 'Question from site %s'; public $wait_time = 60; public function __construct() { $this->site_name = Config::get('concrete.site'); } public function add() { $this->createTable(); }
Something's wrong here. Without this site name code, everything works fine, in particular while adding the block, the database gets updated. As soon as I insert that site name thing:
first, it stops loading the email from the DB, and can't save anything to the DB with this error:
public $email_to = ''; public $site_name = ''; public $email_subject = 'Question from site %s'; public $wait_time = 60; public function __construct() { $this->site_name = Config::get('concrete.site'); } public function add() { $this->createTable(); } public function save($args) { $args['email_to'] = isset($args['email_to']) ? trim($args['email_to']) : ''; $args['site_name'] = isset($args['site_name']) ? trim($args['site_name']) : ''; $args['email_subject'] = isset($args['email_subject']) ? trim($args['email_subject']) : '';
Viewing 15 lines of 24 lines. View entire code block.
first, it stops loading the email from the DB, and can't save anything to the DB with this error:
An exception occurred while executing 'select * from MyForm where bID=': SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
I'm trying to add an admin user name or email address
And I get the same error: syntax error, unexpected '(', expecting ',' or ';'
I've got that code from the system Form block. How come it works with the system block, but nothing works in my own block?
use UserInfo; ... $adminUserInfo=UserInfo::getByID(USER_SUPER_ID); $this->email_to = $adminUserInfo->getUserEmail(); or this: $u = new User(); $ui = UserInfo::getByID($u->getUserID()); $this->email_to = $ui->getUserEmail();
And I get the same error: syntax error, unexpected '(', expecting ',' or ';'
I've got that code from the system Form block. How come it works with the system block, but nothing works in my own block?
I'm not sure what's going wrong now. And I prefer working on my own things now so I won't dive into this question anymore. I hope you'll find someone who can help you. :-)