What are the Slack Archives?
Itโs a history of our time together in the Slack Community! Thereโs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonโt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hi everyone! I would like to display a dedicated screen for new users where they can configure some
Hi everyone!
I would like to display a dedicated screen for new users where they can configure some essential components in the beginning.
I was thinking to set a cookie if the user has already seen the introduction screen and depending on that cookie I either redirect all requests to /introduction
or just do nothing in case the cookie is set. My first attempt was to look into RouterDependencyProvider
and manipulate the routes depending on the cookie, but I think it's a dead end.
Any suggestions how I could implement such a route manipulation?
Comments
-
How about doing conditional redirects in Controllers based on the presence of the cookie?
class HomeController extends AbstractController { /** * @param Request $request * @return View|RedirectResponse */ public function indexAction(Request $request) { if (!$request->cookies->get('foo')->has('bar')) { return $this->redirectResponseInternal('introduction'); } ... } } class IntroductionController extends AbstractController { /** * @param Request $request * @return View|RedirectResponse */ public function indexAction(Request $request) { if ($request->cookies->get('foo')->has('bar')) { $this->addInfoMessage('You\'ve already passed the introduction'); return $this->redirectResponseInternal('home'); } ... $request->cookies->set('foo', 'bar'); } }
Will your user be browsing as a guest or logged in? If the latter, I'd suggest to not use a cookie, but flag the customer account in the database instead.
0 -
Hi, thanks for your response!
I was also thinking about such an implementation but this has the drawback that new users must always pass the
Homepage
and if they would enter another URL (e.g. a promotion link), they would not see the introduction screen.But since this only applies to first-page visits I think this might be fine. Thank you for also pointing out to store such information in the customer account table.
0 -
Okay, then you might check the
RouterDependencyProvider->getRouterPlugins()
. Maybe you can extend the YvesRouterPlugin to add your cookie handling inside the Router. The Router implementation is also having some plugin processing inside, maybe you can use it for your needs.
vendor/spryker/router/src/Spryker/Yves/Router/Router/Router.php0 -
Thanks for your tip, I'll look into it!
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 930 Developer Corner
- 788 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K ๐ Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random