Zend_Translate vs Zend_Navigation - zend-framework

I build a internet application with multi languages. I setup everything well, it work when I call as an example site.com/fr/ I get all in france or site.com/en/ all in english.
I try to get these languages also in my zend_navigation url's like the example above.
for the navigation config I use the application.ini
I hope someone can explain this part or give me an example how I put the 'lang' parameter in the url build by zend_navigation trought the application.ini
With kind regards,
Nick

To get the selected language in the url of the navigation dont start the uri by '/foo/' but like 'foo/'
example application.ini
resources.navigation.pages.popular.label = nav_popular //zend_translate
resources.navigation.pages.popular.title = nav_popular //zend_translate
resources.navigation.pages.popular.uri = popular/
resources.navigation.pages.popular.resource = "popular"

Related

Import content from different CMS into episerver database

I am working on migrating a legacy CMS onto EPiServer CMS. I want to move the content from legacy CMS into EPiServer's database. Anyone ran into a scenario like this? I followed their document on world.episerver.com, but it is not very clear. It says to configure EPiServer site under config tab in Admin section to define Content Channel. But they do not talk about exactly what APIs to use and how different fields map in their database to EpiServer's database. Any help would be much appreciated.
You should not copy directly into the database since it is extremely difficult to get it right.
You need to start by building up your content types inside your project and then I think the easiest way to import the content would to build scheduled task or extend the admin interface with a import page.
In that you do your own mapping since you are the only one that knows what the things in the old CMS should be in EPiServer.
This is not an easy thing to do if you are new to EPiServer and I think that it might be the quickest way to contact expert services and they will then help end guide you.
Good luck!!
You can add page programmatically using EpiServer's IContenntRepository and IContentTypeRepositoiry as follows:
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.ServiceLocation;
PageReference parent = PageReference.RootPage;
IContentRepository contentRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentRepository>();
IContentTypeRepository contentTypeRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentTypeRepository>();
PageData myPage = contentRepository.GetDefault<PageData>(parent, contentTypeRepository.Load("StandardPage").ID);
StandardPage standardPage = contentRepository.GetDefault<StandardPage>(parent);
myPage.Property["PageName"].Value = "Name";
myPage.Property["MainBody"].Value = "My Page";
myPage.Property["PageTypeName"].Value = "Standard Page";
myPage.Property["PagePendingPublish"].Value = true;
myPage.URLSegment = EPiServer.Web.UrlSegment.CreateUrlSegment(myPage);
contentRepository.Save(myPage, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);

configuration in Zend Framework

i am new to ZF and i am making a project in ZF .i got basic knowledge of ZF but need more.
i studied configuration in ZF in many different ways like
Using Array Configuration
Creating File Configuration
Using INI File Configuration
Using XML File Configuration
i need to know what is best and efficient way among all these in sense of Maintainability and security ??
also can anyon plz tell me (Quick advise) how to start my first project so that its easy for me in order to maintain and upgrade.i am bit confuse with layouts that is header , footer and sidebar etc
how to intigrate this in my bootstrap like this but its not working
// Register the autoloader
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
// Initialise Zend_Layout's MVC helpers
Zend_Layout::startMvc(array('layoutPath' => ROOT_DIR.'/app/views/layouts'));
For configuration the answer is: use what you like best. All Zend_Config classes have same functionality. They just differ with the syntax.
As for something not working you must write more details. Again - what do you mean by 'not working'? What are the errors?

How to get request properties in routeStartup plugin method?

I'm developing a multilanguage application, and use routes with translated segments. For multilingual support I created special Multilingual plugin.
To use translated segments I need set translator for Zend_Controller_Router_Route before routes init. So only possible place for this in my plugin is routeStartup method, but there is one problem here - for determine right locale I need to use properties of request (Zend_Controller_Request_Abstract), like module, controller and action names, but they are not defined yet here in routeStartup method. They are already defined, for example, in routeShutdown - but I can't set translator for route there, because it have to be done before routes init.
So what can I do:
can I get request properties somehow in routeStartup
or can I re-setup translator later in routeShutdown
P.S: there is a question with exactly the same problem Zend_Controller_Router_Route: Could not find a translator, but proposed answers is not the option for me, because I can't just retrieve language code from url with Regex, I have much more complicated code to define right language code.
Thanks.
What about putting your code in preDispatch? That's what I personally do when I need to check if the person is logged in. Maybe you can move your code there too?

zend framework under document root in subdir

I developed a application with Zend Framework and now I want to be able to place the app in an subdirectory of a Documentroot.
e.g. http://www.example.com/myapp/
I read quite a lot of Docu how this could work, but all in all these solutions don´t fit my needs. Is there a trivial way to do the subdir thing, without adding the concrete path to any file which generates the pages.
There are some examples in the net, where a basePath is set in the application enviroment and so there is a method call bevor each "form" creation which prepends the path before the link.
$form->setAction($this->_request->getBaseUrl() . $this->_helper->url('sign'));
This was from: http://johnmee.com/2008/11/zend-framework-quickstart-tutorial-deploy-to-a-subdirectory-instead-of-web-root/
But this is only works for small examples, I have tons of forms, tons of views and tons of scripts. I can´t belive this (lets call it hack :) ) is the only solution to do this.
Any ideas?
You don't have to do anything special. See my tutorial at http://akrabat.com/Zend-framework-tutorial which is developed entirely within a sub-directory.
As they say on the web page:
I’m told this last issue has been
lodged has a defect and not necessary
from releases “1.7″ and beyond. The
helper->url will henceforth prepend
the baseUrl to its result.
So you should be fine. Do you actually use the $form->setAction() method on every form already? Because if you use it in combination with the url helper, the baseUrl will already be included.

Zend Framework and switching view script paths

I have a problem. Basically, depending on whether a user goes to /es or /br or /cn etc on our website, we have different language template files. So far, we were using a custom templating engine to make this work, but are making a switch over to ZF. I can't seem to figure out how to get ZF to look for a view script in say cn/about-us if the language varuable is cn.
I can't (don't want to) use Zend_Translate for this because we have way too many translated template files and it's just not feasible using Zend_Translate for bazillion different files with multi-paragraphs of Chinese/Korean/Japanese, forgetting for a second that I don't speak those languages.
Can anybody help me?
You can write a controller plugin and use it's routeStartup() method to alter Zend_View settings (path to where your view scripts are located) and change the request uri before routing starts.
class My_Controller_Plugin_LanguageSwitcher extends Zend_Controller_Plugin_Abstract
{
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
// examine the $_SERVER['REQUEST_URI'] and look for your language identifier
// fetch the View and set appropriate view scripts path using setScriptPath() method
// strip the language identifier from your REQUEST_URI
// change the request uri using $request->setRequestUri('your-new-uri-without-the-language- identifier');
}
}