How to integrate vue with custom routing into an existing regular website? - vue.js

I’d like to integrate vue into a existing webproject. In detail I want to use vue to integrate data from www.autoscout24.de into a website which basically uses Modx-cms, which means that the routing generally takes place inside Modx. With vue I want to realize a search form which I can integrate anywhere inside the existing website. The results should display under something like domain.tld/cars and a single car should be displayed at something like domain.tld/cars/cardetails#8574746
So regarding the routing I guess /cars and /cars/cardetails will be regular sites of the cms (vue only shows the data) but the Hashtag-routing for cardetails will be handled by vue, right?
As the App (should I call it three different apps?) will not be a SAP how can I pass data between the search form, /cars and /cars/cardetails#xyz? Is local storage the way to go?
Is that the right approach. Maybe my approach is even completely wrong, as I am new to vue?
Some further details regarding the app:
The searchform will react to every user input with a request to the Graph QL-Api in order to show the user live how many results he will get. Above the form there will be a teaser with around 10 random cars. After submitting the form the user is directed to /cars where he receives his resultslist (photos of the cars + some quick information). Above the list I want to show the filters so the user can adjust the resultslist. When the user clicks on the car he will get directed to /cars/cardetails#xyz where xyz is the id of the car in order to fetch the cardetails from the api via js/graphql.
Kind regards
Here are some screens to illustrate it. The parts which should be realized with vue are marked red.

Related

Vue navigation between two different apps/domains

I have a Vue 2 app that I'm working on and it kind of works like a search engine - I have a search bar where I can look up any term and when the search runs, results containing that specific term will be displayed.
Now, every result behaves like a link - if I click on it, I will be redirected to a totally different app, which is made in Angular (not sure if this is relevant, I guess you could think only that I navigate to a whole different domain and leave my Vue app).
The issue is that if I click the "back" button in my browser, I will not have the results that I left from, because once I leave my Vue app, its data is deleted.
I was thinking of storing the url containing the search term in local storage and get it when I open the Vue app again, but I don't think this is an option, as it would also behave like this if I refresh the page - moment when I want to have no search query at all.
Please ask for any clarifications needed.
Any suggestions on what could be done are appreciated.

Liquid - get product ID and display custom/specific information dynamically

I am trying to add a small 'lockup' / promo to a page that loads information dynamically based on page.metafield information. Replacing images, video ID's etc. Which all works just fine.
My client is asking for a small area to display a product that relates to this dynamically changing content and I am struggling to come up with a good way to do this.
The current setup is that we have 30 pages with a set of 8 metafields each page. Each one of these pages must show a different , single product with an image, title, price, buy button and another button that links out to a partner site.
I can create snippet and load almost all of this info through metafields manually (price, title etc the client could just add to another metafield) but I would prefer to load a product to pull this info so it can be added to cart. Although I can add product data manually, I still don't actually know which product will get added to the cart, because I'm on a 'page' not a 'product'.
The products themselves are using a custom template that is different to the rest of the site so that seems like its not an option. The template for this content page is just 'page' but surely I can call the product object someway? If the client entered a product ID in the metafields, is there a way of pulling that IDs data easily?
Whatever you mean by pulling ID's, but there are a couple of ways of dealing with this. One, you have a Storefront API token, allowing you to freely and securely call Shopify with JS and get back all the data about the ID you're interested in. Or, you have an App installed in the store, in which case you can setup and callback an App Proxy, providing that ID, and getting back all the info you need. Lots of options!

React Native. How to render dynamic catalog's menu (React navigation)?

Lets imagine, that we have some catalog, let it be the goods catalog.
You have top level categories and many subcategories for them and so on deeper. The whole menu can be of any deep.
Of course I don't want to hardcode this catalog, I want to load its structure from a remote server (REST API for instance), so that I could change it any time wothout posting changes to apps (App Store and Play Market). I am using React-navigation (if it makes any sense). How it is usually done?
(1) Should I somehow create one page and pass there some parameters, or (2) should I create many distinct pages.
In the first case (1) I can't even imagine, how can I pass new
parameters to the same page again and again in such a way that each time
there would be a new title in header of this page and a new submenu
structure to be displayed.
The second way (2) seems rather complex to me and is not the best
idea... I suppose.
What are best practices?

Creating a URL & setting Vue.js Vuex state from its parameters

I have a SPA built in Vue.js that lets the user input several values to create something like a recipe. All these values are stored in Vuex state. I would like to be able to create a URL using the state values that the user entered so that another user can load the app with those values already entered. Essentially I want to allow users to share the recipes they created in my app by sharing a URL.
I'm imagining a "share" button which will copy the created URL to the user's clipboard which they can then post on social media or whatever. Then when someone visits the link, they will go to my app and the vuex state values will automatically be updated to the parameter values found in the URL.
What is the best way to achieve this functionality? Is this something that is possible with vue-router?
Use the $route.query property provided by vue-router.
Pass in a parameters through your URL like http://example.com/#/?amount=10 and access them with this.$route.query.amount.
Update your vuex store in the main component's mounted() method.
Official Documentation for the Route object
If I understand you correctly the vue-router should do exactly that.
have a look at the documentation where they send the user id. You can pass as many parameters as you like.
https://router.vuejs.org/en/essentials/dynamic-matching.html
note: you may consider rebuilding application paths using the router.

How do I connect my appixia app to my prestashop contact page?

I've added a contact button on the title bar but I can't get my contact form to display. Has anyone done this?
First of all, the contact button Module field should point to a new Activity module like VerticalContainerActivity which should contain an HtmlView module in its body. This HtmlView displays your contact page - put the address in its ContentUrl. Most of these steps are identical to what you'll find in this tutorial.
You can see an example of this in the diamonds sample app. Create a new app from the diamond store starting point and see how the contact button is implemented there.
The second important point to remember is that you shouldn't use regular store URLs in your Appixia app. When the user sees them, they would see your Prestashop theme with all the navigation and this will be very confusing inside a mobile app. Instead, make a mobile friendly version of your contact page which doesn't use your Prestashop theme and only shows the contact info content.
Using the Prestashop Contact Form in your Appixia app:
I'm not sure this is a 100% good idea in terms of usability. I don't recommend using a web form for contact in a mobile app.
A mobile phone is a communication device. It is has special integration for making phone calls and sending emails - I really recommend you use these methods instead. Look at the HTML source of this example to see how simple it is to integrate (it's just a link in your HTML).
In order to encourage your users to contact, you need to ask them for as little info as possible. Your website contact form makes your users type in their email address. If they email you directly through their device (with a mailto: link), their correct email will be filled automatically. Same with making a call, when they tap on the link, the number will be dialed automatically for them.
If you really insist on implementing the Prestashop contact form, this will require some Prestashop php games. You should find the contact form controller in the Prestashop source and create the same form (in php or hardcoded HTML) without your website theme. It will be a little annoying because after we submit the form, we also need to make sure the confirmation message is also displayed without your website theme.