Sharing Gallery Between Multiple Wordpress Sites - php

I'm looking for a solution that allows multiple websites to share the same table/database for just the gallery page.
The scenario is that one website will host all the images uploaded while the other website will pull images from that site and filter them to only have the ones relevant to itself. I only want to share the table/database for just the gallery images and not other posts.
Does anyone know if there is a solution that already exists for this kind of problem?

Shared databases (it's called a remote database when accessing one not on your domain/server) are possible, but they tend to get pretty hairy very quickly.
You'd be better suited to use the WP REST API to query posts (if it's a custom post type (also note if it is a custom post type, you may need to register the endpoint on the API: Read more here)) or if it's media library files, you can query media directly using http://v2.wp-api.org/reference/media/
This exact scenario is almost exactly what the v2 API was designed to deal with, and it will save you an enormous amount of stress instead of relying on two installations working on the same database.
Alternatively, you could host the images on a CDN and make queries to the CDN based on that particular site's needs.

Related

Nextcloud Uploader

I just got some questions, maybe some of you can answer.
The benefit by Nextcloud / Owncloud and so on is more than just uploading taking files with you and so on.
It does version the files, make them downloadable - as well secure behind.
It would be benefitial for me and most everyone who is dealing with the Question:
"How to upload documents, link them in some kind of Database (which main purpose is to operate with information) and versioning, saving, editing and so on does not need to be implemented by me / others, because it is handled by Nextcloud (in my case prefered)?"
Is there any script outside, or maybe some kind of plugin to have that benefit?
In my vision I would need:
One "Drag and Drop" Area for Documents / Pictures etc.
This should have a hidden field, which is filled with a id, with which the system can identify the file.
a onetime Link (with retention of that link by one day or so) what is generated by php (could also be a script) and generates a share Link for given id.
(not needed since now, but nice to have:) some script as in 2, where versions of some given File should be viewed.
Some solution could be:
something similar to an "iframe" for a shared link with public upload.
But Im not very happy of using IFrames... Something better would be nice.
Drag & Drop is available in the Web UI. For additional meta data, use a hook mechanism on postCreate (\OCP\Files\Node $node) within a custom app/module you'd need to deploy. For hooks, see https://docs.nextcloud.com/server/12/developer_manual/app/hooks.html.
About meta data: you don't need to store them in a database necessarily, you can also use custom WebDav properties. I wrote a blog post about it recently: https://medium.com/#mathiasconradt/how-to-assign-custom-meta-data-to-your-documents-on-nextcloud-23356cf3f926
Links with a time limit to be valid can be generated manually via Web UI. If you need it automated on upload, use the same approach as in (1): hook mechanism that listens to file creations, as part of a custom app.
at the moment, you can only restore old versions. I think you cannot diff/view them. Would require a custom app.
General info on how to write your own module / app: https://docs.nextcloud.com/server/12/developer_manual/app/index.html

Serving different media files based on view port size

I'm working on a Laravel App and I would like to serve the content based on the user's viewport size. My app requires user login.
When the user logs in I'll also get the device view port size and store it in the session variables. So whenever a particular view is requested I can check the view port dimensions stored in the session and serve the content based on that.
My question: Is there any better way to achieve what I want?
Edit
I know responsive design. The trouble I'm facing with the CSS media queries is the tables. I've hard time making the tables responsive and present them meaningfully. And I've several pages with table data in my app. So I thought I can use the above approach.
I can even optimize the mobile pages to load the fewer resources. I don't want all the features available on desktop to be in mobile. This means that right now my webpage has hidden content, unused plugins and resources on the mobile devices.
So instead of loading the content and 'hiding' it, why not just load the minimum data(and resources, plugins) required for the mobile devices?
Edit 2
After further research I found answers to my questions. I found that there is whole new concept of dynamic serving, which is adopted by most of the large sites. Often it is difficult to achieve everything with CSS media queries. And the css code can get cluttered.
Also the frameworks like Laravel makes it easy to manage the different views. So in such cases dynamic serving can be helpful.

Cakephp: Displaying profile pictures for users in cakephp 2

Hie guys i am still learning cakephp so this question might be easy but im struggling. I have a view.ctp that is currently displaying a buyer's profile like personal details, in addition to this i also want it to display a profile picture for the buyer as well. I have a field in the buyers table called prof_pic which is using longblob data type. I can view the profile of the logged buyer, now i want them to view their profile picture and the personal details as well. How do i do this? Thank you
save image in folder
then you can easily use it ... resize or crop as you like ..
that's simple and easy way :)
You should consider saving your files in the filesystem instead of the database. Florian Krämer from CakeDC did a nice writeup of why to do this. In short:
Storing files in the database is in nearly all cases a bad solution
because when you get the file it has to go its way through the
database connection, which can, specially on servers that are not in
the same network, cause performance problems.
Advantages of storage in the file system:
Easy and direct file access, to parse them (csv, xml...) or manipulate them (images)
You don't need to install any additional software to manage them
Easy to move and mount on other machines
Smaller then stored in a DB
He started an interesting implementation of a plugin to do this. It makes use of the Gaufrette filesystem abstraction layer and makes working with files in Cake much cleaner. A way to scale Images to your needs with the Imagine plugin is also already provided and you're even able to host your images on Amazon S3 and the likes if you're running a high traffic site.

HTML/CSS Templates

I am currently trying to figure out a way to create templates for a number of pages that look exactly the same. The only thing that is different is the content part.
I have worked with PHP and include() to separate several parts of my pages, but still need something that allows me to set a default layout and styling of an entire page since I will be creating thousands of pages that are identical.
Please help me with some tips! Highly appreciated.
thousands of pages that are identical.
As stated in the comments, you should definitely go with a CMS (Content Management System)
Main features of a CMS:
Allow for a large number of people to share and contribute to stored data
Control access to data based on user role (i.e., define information users or user groups can view, edit, publish, etc.);
Facilitates storage and retrieval of data;
Control data validity and compliance;
Reduces duplicate inputs;
Simplify report writing;
Improve communication among users.
Define data as almost anything: documents, movies, texts, pictures, phone numbers, articles etc.
Content Management of Pages
Reference: http://en.wikipedia.org/wiki/Content_management_system
With that said, unless you want to spend countless hours studying and learning (which is not a bad thing) but it seems that you simply want to get this sophisticated website working, then a CMS is what you really need.
Take a look at what i believe are the top CMS's out there:
Joomla
Wordpress
Dupral
In a nutshell, you just need to get your Host, http://www.godaddy.com/ (not my personal favorite) but for simplicity; godaddy will install the CMS for you with a click of a button, it will setup everything and get you up and running! After that is complete, you can login via the administrator panel and play around with the settings to see how things work.
I would start with WordPress, heres a nice site to get you going once you have everything setup (assuming you go for Wordpress CMS)
http://www.siteground.com/tutorials/wordpress/wordpress_start.htm
http://codex.wordpress.org/Site_Design_and_Layout
Have fun! Hope this helps.

Can I use Wordpress as an API to load content to my site?

I'm using Wordpress to manage posts in my website, but I don't want to use Wordpress template/visualization. I will use it only to manage the content and program a bit to display the content in my website.
Well, I can access the Wordpress database and load the content with my own queries. But I want to know if is viable to use Wordpress to create the bridge between my site and the Wordpress database.
Simplifying, I want to know if Wordpress provides methods like getAllPosts(), getAllComments that already manage the database connection, queries and returns some objects or I need to build this in my application.
Not native wordpress, but this is very "viable" through plugins. Example: http://code.google.com/p/wordpress-posts-api/ that claims to do what you want for posts, and you could expand to load comments as well - or you may find an exact plug in that you want with a bit of searching.
I've never actually used one written by someone else for this, but have built similar functionality to expose posts etc for XML feeds (then displayed in Flash, for example). Relatively easy if you start with someone else's plug-in and expand.
Just one word of warning - these plugins are great as the operate in the full WordPress environment, so are easy to run. The downside is that they operate in the full WordPress environment, and are therefore inefficient under high stress. If you're going to hammer it, I'd write a caching buffer first, and only make the full call to WordPress when the cache expires.

Categories