Using multiple Subdomains on TYPO3 and RealUrl - typo3

I have TYPO3 (4.5) installed and a running project. The RealUrl extension is installed and enabled. Everything works as it should. For a proper user of the RealUrl extension i needed to add a few lines of code to the main template.
config.simulateStaticDocuments = 0
config.baseURL = http://www.example.com/
config.tx_realurl_enable = 1
Now i need access to the site by different sub-domains (eg "www1"). I tried the code below, but it is not working. I am not sure about the script i came up with.
host = example.com
[globalString = IENV:HTTP_HOST=www.example.com]
host = www.example.com
[globalString = IENV:HTTP_HOST=www1.example.com]
host = www1.example.com
[global]
config.simulateStaticDocuments = 0
config.baseURL= http://{$host}/
config.tx_realurl_enable = 1
Is this sufficient to keep the system running?

Variables need to be registered at the constant part of the template. TypoScript is no scripting language, but a treebuilding definition set.
I suggest to skip variables alltogether and instead append the following to the end of your TypoScript.
config.baseURL = http://example.com
[globalString = IENV:HTTP_HOST=www.example.com]
config.baseURL = http://www.example.com
[globalString = IENV:HTTP_HOST=www1.example.com]
config.baseURL = http://www1.example.com
[global]
Additionally you should use config.absRefPrefix instead of config.baseURL.

Related

Override favicon.ico with addon in hybris

How can I override the favicon.ico in the Hybris using an addon?
I tried to overwrite the property img.favIcon but it doesn't work
As favicon.ico is rendered through master.tag of the storefront, so it would better you directly change it in the storefront itself, otherwise, you need to create master.tag file in your addon and also need to override all its references so it starts pointing to your addon master.tag file.
Simplest
Just override OOTB favicon.ico with your favicon.ico in the storefront. It's done.
Using javascript (Not recommended)
Copy your favicon.ico at the below-mentioned path in your addon (e.g myaddon)
/myaddon/acceleratoraddon/web/webroot/_ui/responsive/common/images/favicon.ico
Add below javascript in your addon js file (e.g. myaddon.js)
(function() {
var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = 'https://www.yoursite.com/_ui/addons/myaddon/responsive/common/images/favicon.ico';
document.getElementsByTagName('head')[0].appendChild(link);
})();
Build and start the server
ant all && hybrisserver.bat start
I found the solution I copied the Theme.properties to the addons and changed the path

How to run custom php script from doc root in magento2

I wanted to add custom php script to magento2 root folder and run from the browser.I tried to add it in magento2 root folder but it redirects to 404 page.
I also tried to add it in pub folder but no success.
Also cleared cache and empty generation folder.
I am using nginx server
If you are using nginx configuration that comes with magento you need to put a file inside pub folder to allow access to it from the browser as pub is the document root of the vhost. Magento root dir is one level up. Second of all default config for nginx allows only to access index.php, get.php, static.php, report.php, 404.php and 503.php files. Any other are not processed by the php. You can see this in line with location ~ (index|get|static|report|404|503)\.php$ { in nginx.conf.sample. If you are not using it check your config for similar rule. To allow another file to be accessible from browser simple add another name after 503 or change entire brackets with location ~* \.php$ {
Source: https://magento.stackexchange.com/a/97290/1883
For example you can get product name in custom script by this step
step 1: create index.php at root of magento 2
magento2/test/index.php
<?php
require __DIR__ . '../../app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication('customScript');
$bootstrap->run($app);
step 2: create customScript.php
magento2/test/customScript.php
<?php
class customScript
extends \Magento\Framework\App\Http
implements \Magento\Framework\AppInterface {
public function launch()
{
$this->_state->setAreaCode('frontend'); //Set area code 'frontend' or 'adminhtml
$id = 12;
$_product = $this->_objectManager->create('\Magento\Catalog\Model\Product')->load($id);
echo $_product->getName();
return $this->_response;
}
public function catchException(\Magento\Framework\App\Bootstrap $bootstrap, \Exception $exception)
{
return false;
}
}
Now you can run this custom script by
http://10.16.16.196/magento2/test/
As stated by #Ranjit, the /pub folder must be your Magento root folder.
The correct way to run a standalone php script on Magento would be:
On nginx:
Locate location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ { and add your file there.
I.e:
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check|myphp)\.php$ {
Then you can access yourstore.com/myphp.php.
On Apache:
Simply add the file under /pub folder. I.e.: /pub/myphp.php.
Apache rewrites rule will redirect to index.php if the file or folder doesn't exist.
In my case on Apache (cPanel) the problem was that file permissions of .php files should not be writable by group or others to be served directly, else Magento's 404 would open.
So in my case to serve file directly I had to set file permission to -rw-r--r-- (on Linux).
This is the mostly issue with servers using suPHP.
Putting this here in case someone runs into same situation...

XDebug doesn't stop on breakpoints set on Yii controllers' actions

I code in Yii framewor, using Netbeans 8.0.1 and also Eclipse. My local developement environment is build on XAMPP. I can see, that breakpoints set anywhere within Wordpress code works just fine. But, when I try to set a breakpoint on any Yii's controller or action, XDebug won't stop at that point. It only work on index.php of my project.
However, xdebug_break() work for controllers, but not actions.
My php.ini settings for XDebug are:
[XDebug]
zend_extension = C:\xampp\php\ext\php_xdebug-2.2.5-5.5-vc11.dll
;xdebug.profiler_append = 0
;xdebug.profiler_enable = 1
;xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = 127.0.0.1
xdebug.trace_output_dir = "C:\xampp\tmp"
xdebug.idekey=netbeans-xdebug
xdebug.remote_port=9000
xdebug.remote_log = "c:/xampp/tmp/xdebug_remot.log"
xdebug.show_local_vars = 9
xdebug.max_nesting_level = 250
xdebug.auto_trace=1
xdebug.remote_server = 127.0.0.1
I'm trying to deal with this problem for about a week and still didn't come with any solution.

Typo3: How to set [FE] [activateContentAdapter] variable to 1

How can I change a configuration variable through the backend panel in Typo3?
I need to set this line in the global configuration from
$TYPO3_CONF_VARS['FE']['activateContentAdapter'] = '';
to
$TYPO3_CONF_VARS['FE']['activateContentAdapter'] = '1';
Do I have to use the installation tool ?
In the backend, go to Install Tool > All Configuration
Expand $TYPO3_CONF_VARS['FE']
Check [FE][activateContentAdapter] = 0
This solves the distribution.png issue.
In TYPO3 6.2 the contentAdapter is active on default, if not explicit set to FALSE in your LocalConfiguration.

Setting output_style for SCSS using Compass in Sinatra app

I'm looking at the Compass-Sinatra starter file on GitHub. Is there a way to set the output_style for an scss file in Sinatra? Ideally I would like to set the style to :expanded when in development.
I think I'm having trouble understanding how sass(:"stylesheets/#{params[:name]}", Compass.sass_engine_options ) works and where I can set those options.
I found that adding the output_style setting to the compass.config file works for changing the output_style. It can either go in the if defined?(Sinatra) block or in the configuration block at the bottom of the compass.config file.
# compass-sinatra-starter/config/compass.config
if defined?(Sinatra)
# This is the configuration to use when running within sinatra
project_path = Sinatra::Application.root
environment = :development
output_style = :expanded # This is where you can set the output_style
else
# this is the configuration to use when running within the compass command line tool.
css_dir = File.join 'static', 'stylesheets'
relative_assets = true
environment = :production
end
# Or if you wanted to have the output_style set for all environments(?)
# This is common configuration
output_style = :compressed
sass_dir = File.join 'views', 'stylesheets'
images_dir = File.join 'static', 'images'
http_path = "/"
http_images_path = "/images"
http_stylesheets_path = "/stylesheets"
Note: stop/start the server if you change the settings if you don't see the change.
For example, I have a styles.scss file in views/stylesheets/styles.scss then if I go to http://localhost:4567/stylesheets/styles.css I'll get the .scss file compiled in the browser to .css. Changing the output_style, start/stop the server the .css output_style changes. I don't know if using reloader would work, but it might avoid the stop/start?
I found a couple of other good resources.
Andrew Stewart has a blog post and a GitHub template
Originally I was trying to learn about media queries in Sass(scss) with Sinatra and found a great video Ben Schwarz posted, but it doesn't go into the nitty gritty of setting up. It's more about the media query. Ben also has the source on GitHub.
But it seems like AssetPack is the best way to go for serving assets.