Firebase Dynamic Links with parameters - firebase

I have a custom domain setup with Firebase Dynamic Links. The URL prefix is https://example.com/link and I am then able to create a new dynamic link that will resolve https://example.com/link/article to https://example.com/article within my app or on the website.
What I need to do is also pass the ID of the article that I want people to see. The copy writers need a URL structure that lets them cross-link articles, so it needs to be a URL like this: https://example.com/link/article?id=123456 but when I test this in the browser it resolves to https://example.com/article .. this should be possible right? I shouldn't have to create a dynamic link for every single piece of content should I? Would I need to add https://example.com/link/article/123456 so it links to that specific article?
If I were to create Dynamic Links using the REST API in a Cloud Function that is triggered when new content is added to the Firestore, would these links persist?
I know that using the long Dynamic Link format will give me what I need, as I can create the short URL with the param added. But this doesn't solve the issue of giving the Copy Writers a URL structure that is easy to use in their content. Maybe a Cloud Function that strips out the URL links from the body copy, and replaces it with the long-form Dynamic Link?

Related

How to embed external backend content to wordpress?

I have a front end website using Wordpress that I wanted to display some data from our backend website on.
I am having trouble figuring out how to set it up. In theory I could iframe a small part onto the page to list a small table on it but then the table formatted data would not be searchable from my wordpress search. Does anyone have any recommendations? My data that I want to embed could be anything I want to return but usually it will be text. It could be JSON, HTML, etc.
I have a feeling my only option would be to build a sync function that imports all my backend data to the wordpress database to then call into my page.
Your task consist of this parts:
Import data from your backend website. There are couple of ways to
that: if your backend website has a kind of API you can access data using wp_remote_get or use files for exchange data
(backend upload and frontend website read the file).
Save data in the WP. Here you can use WP Options API Or you can use wpdb object to interact with WP database.
Display data using Shorcode API
Depended on size of your data, it may be possible to skip step two and display imported data without storing.
If you are not worried about having that content indexed in the WP search, you could use the wpdb class.
https://codex.wordpress.org/Class_Reference/wpdb

Create custom wordpress url to query data from external database

so, I have a Wordpress Setup with a custom homepage template. In the template I query some products from an external database. Now I want to create a detail of a product, and this is where im stuck..
I don't know how to implement this since there is no data in the WP db thus no actual url (I guess?).. I thought about making 1 page in WP called 'Detail' and make the href attribute on the homepage products like this 'www.example.com/detail/123', get the id from the url en with that id query to the database..
Is this the right approach? Hope someone can help..
thanks!
If i understand you right, you want to query content from one wordpress website to another right ?
The right way to do it is to use JSON APIs which will let u retrieve the content you need using HTTP requests.
You can set these APIs yourself, refer to the following tutorial.
Thus, you can also use this wonderful wordpress plugin :
JSON API
After installing and enabling the plugin you'll have to set your API links according to the content you need to get, for example the following api:
http://example.com/api/get_posts/?post_type=custom_post_type&count=3
queries the latest 3 custom posts along with their fields and custom fields (if present).
Find more examples here.
Now on your other website where you want to display the content you 'll need to use JSON decode to convert the JSON string into a PHP obect or array.
For example:
$json = '{"a":hello,"b":hi,"c":hey,"d":yo,"e":ola}';
$data = json_decode($json);
echo $data->{'a'}
// this should echo the value "hello"
As stated here.
I hope that helps !
I don't think he wants to query another WordPress. He only says that he fetches data from another database that contains products.
Your idea is pretty close to what you have to do. Take a look at add_rewrite_rule, add_rewrite_tag and get_query_var.
This tuts is a good example for you: http://code.tutsplus.com/articles/custom-page-template-page-based-on-url-rewrite--wp-30564

Make an alfresco share site Taggable

I am aiming to make an alfresco site Taggable.
When creating a site, I am looking for a simple way (JS, XML) to let users assign Tags to a site.
It can be done by assigning Tags from Repository to the site folder, but what I want is to add Tag field to the site creation form.
Change the create-site.get.html.ftl use the alfresco\components\form\controls\category.ftl as reference to create the tags field.
Then change the sites.post.json.js in org\alfresco\repository\site and get the tags and add them to the site.
You'll probably also will need to change the client-site JavaScript create-site.js to send the actual tags value to the repository webscript.

Set the permalink to any domain in Wordpress

Is this possible to achieve without too much effort or a plugin? It's simply to instantly redirect to a site I've made in my portfolio if the post doesn't have any content.
Note that I don't want a script in the actual post to redirect since I only use Wordpress as the backend and fetch all the data to be used by a JavaScript backbone app.
EDIT : Added some extra info in a comment
Short Answer: No. You cannot set your Post Permalink to an external asset without directly editing the database.
Long Answer: First off, you need to understand the purpose of the Permalink. It isn't just an arbitrary link to somewhere. It's reserved specifically for storing where that specific post lives within the context of your Wordpress installation.
Your post doesn't live on example.com. It has its own ID, and Wordpress has a specific spot set aside for it where it can be seen on YOUR domain. Leave it as such.
Instead, what you should be doing is employing the tools Wordpress gives you to achieve what you want. A Plugin doesn't exist for what you want because - quite frankly - it's a fairly trivial task when approached CORRECTLY and doesn't warrant the use of an external resource.
So what's the correct way?
Use a Custom Field. Name your Custom Field something like 'externalHref' and fill that in with your link to the website you want to point to in case there's no post content.
Then in whatever templates you're using to generate your posts, just check either for the existence of your Custom Field called 'externalHref' or check for the non-existence of Post Content. In either case, instead of generating a link using The Permalink you can simply build a link that points to wherever you need.

wordpress - how let users add location on a map?

I'm using Wordpress to build my website, i want to add a form that will have: name, description, image and location on a map. that is letting the users add their own marker on a map.
and by pressing 'submit' the whole data (name, description, image, longitude, latitude) would be saved to a database.
how can i do that? which plugins should i use?
You could use Google Placemarks and give them access to the creation of the 'Placemarks' custom post type that plugin utilises. You might have to hack the featured image..
Alternatively, you're looking at full custom post type creation and google maps API integration, a custom loop that utilises of the featured image.
Plugin that comes closest to what you need is what SMacFadyen suggested - BGMP. But if you want to do that yourself you would need to look into this:
Google Maps JavaScript API
WordPress Custom Post Types
WordPress Meta Boxes
For the first one there is lots of tutorials on how to display map and InfoWindows so you shouldn't have much problem with that. For Custom Post Types there is an awesome generator which should do 99% of your work. For Meta Boxes you can go several ways:
plugin - easiest but you would depend on a plugin which I don't like very much
from scratch - tutorial - which is a lot better than plugin but requires a lot of work
one of the meta box libraries - this is the way I usually go - I'm developing my own but it's not ready yet so in the mean time I would recommend My-Meta-Box or Reusable Custom WordPress Meta Boxes
Several times, when searching how to make this work, I stumbled upon this thread. Every time, I wasn't really happy with the way existing plugins deal with this. So, I now put this together myself.
Here's an overview of my solution.
Use the plugin Custom Post Type UI to create a custom post type for the markers on the map.
Use the plugin Advanced Custom Fields to add a field to this custom post type which represents the location. The field type is of type 'Google Map'.
Copy the standard Google Maps API clustering example to the appropriate theme file in your theme.
For showing your markers, generate the list of locations by, in your theme file, requesting the posts of your newly created custom post type.
For each marker/location, pick up the 'Google Map' field and abstract the latitude and longitude.
For each marker/location, construct the appropriate array element for the array with all locations, with, at least, the latitude and the longitude, and probably also the contents of an infowindow.
This should give you a map with all locations plotted out.
To allow users to add locations:
Add a listener to your map that listens for clicks and returns the location clicked. Perhaps this listener is only running after the user has expressed his intent to add a location to the map.
When the user has clicked, open a form, for example in a modal. The form should contain hidden fields with the latitude and longitude and could, for example, also contain a static image of the relevant location. Other form fields would be the fields you need for your purpose.
Submit the form using AJAX. Refer, for example, to this tutorial. In your theme's functions.php, you can then validate the submission and add the new submission to your Wordpress database, matching your new custom post type.
Depending on how you store your new location, on your next map reload, the new location will be included. (Or you perhaps need to authorise the new location, first.)
You can also reload all locations through AJAX.
Profile Builder allows you to do just that. Create a front-end register form including the required custom fields and a map field for users to pin or enter their location.
Then using the built-in User Listing (Member Directory) module, you can display a map of all users locations.

Resources