Why dynamic routing is not working as expected in Nuxt js when data coming from vuex or localstorage? - vue.js

I want each question that entered by the user to be turned to a link that leads to a page to discuss and comments on this question solely. So, I have a text area that takes user input (a question ) then save it to a localstorge with previous hardcoded data.
The hardcoded data are rendered properly to valid links to dynamic pages. But those from user input are not working. I checked many questions here I did not find a proper answer to this problem. I want the input of user to work as a link . They all stored together and I am looping them together , so I expect them all to be working as links properly. But those from user do not work as expected:
<table v-for="q in questions">
<td>
<tr class="border-dotted border-2 border-light-blue-200">
<nuxt-link :to="`/questions/${q.id}`"> {{ q.question }}</nuxt-link>
</tr>
</td>
</table>
Computed property to read from vuex:
computed: {
questions() {
return this.$store.state.all;
}
}
Any help?

As stated in the comments, if you want to have something looking like StackOverflow, with various created pages and question + answers, you'll need persisted data.
Vue is client only and therefore, if you have a created question, it'll stay on your own machine (other people will not see it).
So yeah, a backend with a database is required here.
If it's a small project, you could even maybe use an online service like Firebase to have a mongo-like quick and simple DB. Or any other cheap/free service. If you want to go more serious, you'll need to make your own backend. :)

Related

Storing and retrieving data for custom Shopify apps

So I am trying to build something for my store but a few things are somewhat unclear.
If I need to save some user settings do I need my own backend just
for that app specifically? For simplicity sake, I want build an app
to save and display a custom message in cart-template.liquid.To
achieve that, I think my app should make a request to my backend (let
say, on heroku) and save it in some db that app is using?
How do I retrieve that data in cart-template.liquid? I guess I
build a snippet that calls a public endpoint of my backend that
returns that saved message using fetch() or maybe axios.get and
embed it using {% render 'fetch-custom-message-snippet' %} ?
Say I ask for user input, ie. "Engraved message" and the form is in cart-template.liquid,
of course. The following snippet is used:
<p class="line-item-property__field">
<label for="engraved-message">Engraved message</label>
<input id="engraved-message" type="text" name="properties[Engraved message]">
</p>
How do I make sure that bit of information is captured and passed to me? I guess I want to see it somewhere in the order details.
If I need to save some user settings do I need my own backend just for that app specifically? For simplicity sake, I want build an app to save and display a custom message in cart-template.liquid.To achieve that, I think my app should make a request to my backend (let say, on heroku) and save it in some db that app is using?
Yes, you need your own backend. Your application alone is responsible for storing its own information (there are some exceptions like a special order field which I show you below) - that typically infers a database that back ups your service and holds your data. Please check out this thread as you can find lots of valuable information there.
Regarding cart-template.liquid I'd suggest taking a look at the official "Shopify Developers" documentation. All information you're allowed to display and request are neatly explained and ordered there.
How do I retrieve that data in cart-template.liquid? I guess I build a snippet that calls a public endpoint of my backend that returns that saved message using fetch() or maybe axios.get and embed it using {% render 'fetch-custom-message-snippet' %} ?
Once again there are good guides out there. I suggest taking a look at this blog post which goes into in-depth on this topic. Shopify's documentation about the Liquid template language is also highly advised to be read.
How do you retrieve that data? According to this specific example any input will be supplied to your order page in the Shopify admin. For example:
<label for="CartNote">Special instructions</label>
<textarea name="note" id="CartNote">{{ cart.note }}</textarea>
*taken from https://shopify.github.io/liquid-code-examples/example/cart-notes*; shows a Special instruction label and textarea for users to submit details about the oder - you will get this data on, as mentioned, the order page in the Shopify admin.
Say I ask for user input, ie. "Engraved message" and the form is in
cart-template.liquid, of course. The following snippet is used:
[...] How do I make sure that bit of information is captured and passed to me? I guess I want to see it somewhere in the order details.
see above
//EDIT:
To prevent any confusion: It seems like you want to develop a custom app just for personal usage and not to publish it in the Shopify App Store - in this case you most often than not don't need an external database; e.g. the example you provided with a simple order request which is easily doable through Shopify's examples.
For your specific case this code snippet (I modified your original example to fit the case - it's not a full cart-template.liquid obviously; in this case the file is called cart.liquid):
<label for="engraved-message">Engraved message</label>
<textarea name="message" id="engraved-message">{{ cart.note }}</textarea>
//EDIT 2:
The link - shared by another user in this thread, namely #Simas Butavičius - is actually kind of useful if you have problems with the customization process in general, i.e. if you want to revise some basic concepts or want to check how to implement the code snippet from above in the whole structure of your website I'd advise to skim through this site.
Needless to say, there are hundreds of good tutorials, questions regarding the same "issue" or other resources in general.
I suggest for further reading purposes to check out some of these links and guides (some may be mentioned above):
https://shopify.github.io/liquid-code-examples/example/cart-notes
https://shopify.github.io/liquid-code-examples/example/checkout-form (! very good in-depth example)
https://www.christhefreelancer.com/shopify-liquid-guide/
https://shopify.dev/docs/themes/theme-templates/cart-liquid
https://shopify.dev/docs/themes/liquid/reference
https://www.shopify.com/partners/shopify-cheat-sheet (! helpful cheatsheet)
https://community.shopify.com/c/Shopify-Design/Cart-Use-cart-attributes-to-collect-more-information/td-p/613718
https://community.shopify.com/c/Shopify-APIs-SDKs/Add-custom-input-fields-to-cart/td-p/154710
https://community.shopify.com/c/Shopify-Design/Product-pages-Get-customization-information-for-products/td-p/616503
Here is the tutorial specifically for creating custom shopify input field for getting engraving information: https://community.shopify.com/c/Shopify-Design/Product-pages-Get-customization-information-for-products/td-p/616503

Custom "Not Found" option in bootstrap-select when live searching

Using Bootstrap 3, and bootstrap-select v1.13.2
I have created a bootstrap-select with live-search turned on. Below is a simple example.
<select class="form-control selectpicker" id="customer" name="customer" data-live-search="true">
<option>Customer Inc</option>
...
<option>Customer LLC</option>
<option>New Customer</option>
</select>
I would like it to display the New Customer option, if no other customers are matched while using the live search.
I found this answer to a similar question, but I can't figure out where to put that code, and I can't comment to ask for clarification (brand new account).
EDIT:
Apparently the above referenced answer is for a completely different (albeit similarly named) plugin. Does anyone know if what I want to do is possible with the plugin I'm already using? It would be a pain to switch it out over many pages.

Easy way to track a simple input field ?

I'm really new to this website coding stuff, so any help is welcome.
I think my problem is a very basic one, but it seems hard to find the exact thing I'm looking for.
What I need :
First of, a little explanation what I'm trying to build and why.
Soon my girlfriend and I will be going long distance for a significant amount of time. So I wanted to create something like a little, daily calendar she can access with a daily code which leads her to a webpage with a picture/text/video/whatever.
So far so good - managed to get this far with a website. But since those codes will be randomly pulled and entered, I have no idea which code was "used" that day.
What I'm looking for, is a very simple way to keep track of the inputs.
Since I'm not really sure how to go about it, it's hard to find something on my own
Where I'm at:
I have a site which only consists of a background, an input field and a button to submit that input.
That input then gets basically added to the website link to redirect to a subpage.
It looks like this currently :
<input type="text" maxlength="4" id="code"/>
<input type="submit" value="Enter" onclick="javascript:location.href='https://www.placeholderlink.com/' + getElementById('code').value + '.html' " />
So my question in the end would be :
How can I add a quick and easy way to keep track of the codes that have been input on the website ?

django-avatar, 1 query per avatar loaded

I'm displaying a page with around 60 avatars using django-avatar and a query is made for each one of them.
I cannot use User.objects.select_related('avatar') because there is no link between my user and his avatar. So how do I optimize this?
EDIT:
Avatars are retrieved in the template using {% avatar user %} (this is a template tag specific to github.com/jezdez/django-avatar, which seems to be the most used application for handling user avatars. I'm asking this question because some people certainly already had to face the issue of displaying many avatars using this application and I would like to know their solution).
Using the cache (like memcached) is the answer.

Authorize.net SIM Process w/Master Pages using VB.NET returns Error 13 Invalid User

I am trying to use Authorize.net's SIM payment gateway process and am using the base code provided on the developer site. The problem is I am using Master Pages with my site and the hidden field names are getting concatenated with the nested control IDs as an example:
This is what the field should look like:
<input type="hidden" runat="server" name="x_login" id="x_login" />
The output ends up looking like:
<input name="ctl00$MainContent$x_login" type="hidden" id="ctl00_MainContent_x_login" value="MyCode" />
Normally that would not be a problem except Authorize.net is picky about field names apparently since I keep getting Error 13 invalid user. I went through their forums and opened a customer support ticket a week ago, no response other than the automated check our forums email. The closest thing I found on their forums is other people with Master Pages having the same problem with no answers.
I also used their developer response site to check out the values that I am sending them and they all seem to be correct, including the field names. I am at a loss. I can post the entire subset of code but it is the code from their site pasted into my contentholder.
The other work around I have is since my Masterpage already has a form I added these lines of code:
Me.Form.Action = "https://test.authorize.net/gateway/transact.dll"
'Me.Form.Action = "https://developer.authorize.net/tools/paramdump/index.php" This link will show all of the form elements that are submitted.
Me.Form.Method = "Post"
The above lines seem to work properly as the output code looks correct.
Finding no help anywhere else I thought I would ask the people who have not let me down yet.
Here is the answer. After trying a lot of different paths, it is definitely the MasterPage that frags the post to Authorize.net. I tried re-"name"ing the controls among several other things and for time conisderations I gave up trying to resolve the issue and just reformatted the page to not use my masterpage file. I am also building a silverlight e-commerce solution and I am a little concerned that I will not be able to use authorize.net for the same reason.