Mounting TYPO3 FAL storage with another domain - typo3

Using TYPO3 6.1.9 (will be updated soon to latest 6.2).
Is it currently possible to use a FAL storage with another domain? The webspace looks like this:
path-to-web-directories/
- maindomain.com/
- - fileadmin/
- - typo3/
- sub.domain.com/
- - files.txt
In the TYPO3 backend I created a file storage for the directories path-to-web-directories/maindomain.com/fileadmin/ and one for path-to-web-directories/sub.domain.com/. This is really great and work so far. I can manage the files in both storages.
But now if I set a link to a file located in sub.domain.com, the URL looks like this:
http://www.maindomain.com/sub.domain.com/files.txt
instead of
http://sub.domain.com/files.txt
Ist this issue a part of TYPO3 or can I configure this with realUrl (which I'm using)? And how can I do this?

I resolved the problem:
The URL is generated in the class TYPO3\CMS\Core\Resource\Driver\LocalDriver->getPublicUrl
In this case an own extension with a new resource driver is needed.

Related

Setup configurable site base variants in TYPO3

Using TYPO3 >= v9, with Composer
I am using an installation with several sites, the configuration is set up via .env (with helhum/dotenv-connector).
Now, I have several development / test / staging installations with different domain names. It is possible to add additional "baseVariants" to the site, such as
base: 'https://example.org'
baseVariants:
-
base: 'https://dev1.example.org'
condition: 'applicationContext == "Development/Staging"'
But I would like to make this configurable in my .env file. I only want to change the .env, not the site configuration for every installation. And I would not like to set up another base variant for every domain name I might want to add.
Ideally, figure out a naming scheme you can use and use this consistently where you have base domain name and some variant, e.g.
main site: https://example.org
development: https://dev1.example.org, https://dev2.example.org etc.
.env
SHORTCUT=dev1
TYPO3_CONTEXT="Development/dev1"
config/sites/mysite/config.yaml
base: 'https://example.org'
baseVariants:
-
base: 'https://%env(SHORTCUT)%.example.org'
condition: 'applicationContext == "Development/%env(SHORTCUT)%"'
(Official) documentation:
Environment variables can be used in the site configuration.
Application context
Custom application context

Editing buildout.cfg in Plone from a browser

I am editing a website using the Plone 4 CMS. The Plone instance I am currently using is hosted by a server to which I don't have access (i.e. I can't FTP this server and edit PHP files).
Although I don't own the server which is hosting this website, I would like to access the buildout.cfg file. Is there a way to edit this file by just logging in on my Plone website, or do I need to have the credentials to manipulate the whole instance of the site with FTP?
When I log in, I can go to a page called Site Setup (screenshot provided). Can I perhaps solve my problem from this page?
Theoretically it's possible, the code-example below shows a prototype using a browser-view, which when called:
Reads the content of a given page
Writes the content to the buildout-config
Updates the instance
Practically:
You'd need to have access to the file-system, to install an add-on with the browser-view beforehand.
One would never want to do this in production, because if errors occur you
cannot do much about it then.
import os
from Products.Five.browser import BrowserView
class View(BrowserView):
def __call__(self):
# Let's assume these paths exist:
instance_path = '/path/to/instance'
buildout_config_path = instance_path + 'buildout.cfg'
page_path_in_site = 'front-page'
# Read buildout-config of page in site:
page = self.context[page_path_in_site]
config_content = page.getText()
# Write buildout-config to filesystem:
with open(buildout_config_path, 'w') as fil:
fil.write(page.getText())
# Run buildout, so changes in config take effect:
os.system(instance_path + 'buildout')
# Restart server, so python- and zcml-files get
# (re-)compiled, respectively loaded:
os.system(instance_path + 'bin/instance restart')
You can't. The buildout.cfg file is used for installing / building your application. So, when you are in Site setup you already are using the running application you want to reconfigure.
You will edit your buildout.cfg then you will run ./bin/develop rb to rebuild it, then you will (re)start the instance of your application. This is when, for example, you will see new add-ons available for activating them from Site setup / Add-ons (the add-ons you added in eggs / zcml / versions sections of your buildout.cfg).

TYPO3 FAL: absolute path for file storage

With TYPO3 6.2, my site entirely lives in public_html/mydir, which corresponds to mydir.mydomain.com.
Now I would like to place file storages outside that subdomain / directory, say, public_html/otherdir.
So I tried setting the file storage path to absolute and /home/username/public_html/subdomaindir/public/, as such:
This would result in FAL errors in the backend, no file tree displayed anymore, and the storage going offline.
Can this be done, and if so, how?
And, extra question: If I just set a symlink with
ln -s /home/username/public_html/subdomaindir/public/ /home/username/public_html/mydir/public/
would that (also) work?

create a symfony2 service

I am new to Symfony2 and am trying to setup my first service. This is a curl service.
I have followed the directions on the documentation, but haven't been able to get anything to load. I am using version 2.0.1
In my app/config/config.yml I have added:
parameters:
curl_service.class: FTW\GuildBundle\Services\Curl
services:
curl_service:
class: %curl_service.class%
The class file is located in src\FTW\GuildBundle\Services\Curl.php and
it's namespace is namespace FTW\GuildBundle\Services;
The class name is Curl
When I try to load my service with $curl_service = $this->get('curl_service'); the error is get is
You have requested a non-existent service "curl_service".
I think I am missing something very simple... any help would be appreciated!
Make sure you clear your cache at /app/cache/ even in development mode.
It works well on my fresh Symfony 2.0.4 install. Looks like your config is not taken into account. Are you working in dev environment?

CherryPy : Accessing Global config

I'm working on a CherryPy application based on what I found on that BitBucket repository.
As in this example, there is two config files, server.cfg (aka "global") and app.cfg.
Both config files are loaded in the serve.py file :
# Update the global settings for the HTTP server and engine
cherrypy.config.update(os.path.join(self.conf_path, "server.cfg"))
# ...
# Our application
from webapp.app import Twiseless
webapp = Twiseless()
# Let's mount the application so that CherryPy can serve it
app = cherrypy.tree.mount(webapp, '/', os.path.join(self.conf_path, "app.cfg"))
Now, I'd like to add the Database configuration.
My first thought was to add it in the server.cfg (is this the best place? or should it be located in app.cfg ?).
But if I add the Database configuration in the server.cfg, I don't know how to access it.
Using :
cherrypy.request.app.config['Database']
Works only if the [Database] parameter is in the app.cfg.
I tried to print cherrypy.request.app.config, and it shows me only the values defined in app.cfg, nothing in server.cfg.
So I have two related question :
Is it best to put the database connection in the server.cfg or app.cfg file
How to access server.cfg configuration (aka global) in my code
Thanks for your help! :)
Put it in the app config. A good question to help you decide where to put such things is, "if I mounted an unrelated blog app at /blogs on the same server, would I want it to share that config?" If so, put it in server config. If not, put it in app config.
Note also that the global config isn't sectioned, so you can't stick a [Database] section in there anyway. Only the app config allows sections. If you wanted to stick database settings in the global config anyway, you'd have to consider config entry names like "database_port" instead. You would then access it directly by that name: cherrypy.config.get("database_port").