I am facing an issue with wordpress. I have two sites. On the first site there is a form that takes inputs and stores values in custom fields to be later used for various calculations on that site.
On the other website, I need to access these same values from the first website and use them thoughout the second website in multiple elements. So I've come up with an idea that because those stored values on the first website are already being displayed (as in, they are in some HTML elements in a visible page), I could just get that first website content and than do one of two things:
Create similar custom fields in the second website, and write a function in functions.php that would take the values from the first website and update custom fields in the second website every time it loads, so then I could use those values throughout the second website (it seems to me that this is a stupid solution).
Write a function in functions.php (in the second website, the one that needs to receive the values from the first) that would create javascript variables from that first website, so that could be used to populate all the elements I need.
Maybe there is some much better solution for all of this. To be fair, this is the first time I am doing something like this, so you could say I am very unexperienced.
Is there another better solution for this? And if there isn't, which of the two solutions listed above is a better one?
Though there are many possible options and that may generate debates based on individuals' experiences and or prevailing conditions, you can easily achieve your intended goal by consuming data from your site one into your site two, then, apply whatever necessary logic and actions needed there (in your site two).
Using the latest version of WordPress, you can take leverage on the in-built REST API in order to access the desired data from site one within site two.
Related
At my company (a custom retail e-commerce website) we have a homepage with various sections on the page for promotions/sales/events. These sections may appear in any order, one after the other. The order of the sections are saved in a database table called mainpage_sections with an order column (int).
The present method we use for updating the homepage when the order of sections is changed, is by running a callback method that automatically rewrites the aspx View file itself, in HTML, with the new order of the sections. It does not pull the sections from the database and dynamically render them according to their order.
This struck me as being opposite to best principles and very messy. I asked why we didn't use a database read instead, but I was told that since this website is visited thousands of times a day, and the order of the sections rarely changes, it makes more sense to update the file itself, instead of running thousands of extra database reads just for people visiting the homepage of the website.
Does this approach make sense? What is the best-principle, recommended approach here? Is something like output caching a better choice?
Overwriting a code file does seem weird. What if you stored the ordering in a separate JSON file, and only overwrote the JSON file?
So my question is can I use a bunch of steps defined in another scenario that was used in a different feature file?
eg: I have a feature file that helps create some pages on the website. Now i want a different scenario in a different feature file that will create the pages and also add some other steps to it. In this case, I want to create a page, and this triggers a notification to a particular user, and I want to work with the notifications. But cannot do so without triggering a page creation action by the user. It is just a bunch of 5 steps. but i am trying to reduce steps as much as possible to keep it simple.
Of the top of my head, maybe use tags and then use the tags to combine two scenarios. but i am not sure if we can do that
So i want to know if there is a way of code reuse in this case. And if so, HOW?
Thank you
You could define a new step like ‘I create a page’, and under the hood reuse the steps from other contexts as explained here:
https://behat-docs.readthedocs.io/en/mvp1.0/cookbooks/gathering_contexts_when_using_multiple_contexts.html
I have an Episerver site with a JobDetailsPageController with a Index method that takes a jobId parameter and creates a view with some details about that job. The urls looks something like this: https://hostname/<root-depending-on-site-tree>/jobs/?jobid=44.
What I would like is having urls on the form .../jobs/manager-position-telco-44, essentiallly creating a slug of the job title and appending the id. I have done this in the past using standard ASP.NET MVC Attribute Routing on a non-Episerver site, but EpiServer has a routing of its own that I don't know too well and can't figure out.
Also, adding non-query strings after the slash consistently sends me (no surprise) to a 404 page, so I would need to somehow customise this behaviour. I need to use EpiServers standard routing to end up at the right "parent", but ignore the latter part (the pretty bit).
Is it possible to create such urls on a normal page in page tree in EpiServer? I do understand it is possible to create static routes, but this node can be moved around like any other page so I cannot avoid EpiServer.
Please see this blog post. What you're looking for is partial routing.
#johan is right, partial routing is one way of doing this. Just wanted to add other possible solutions that might or might not match your needs.
Import data as content
Instead of serving content dynamically, you could consider importing your job ads from whatever source you have directly in content tree as separate pages below particular root page. That would give you a lot benefits - pages would be cached, it would support multiple languages, editors would see content directly in EPiServer CMS, data could be adjusted manually, etc.
This would be a good solution if your data does not change often and you need to provide a way for editor to create a new job ad manually as well.
Implement you own content provider
Another way to serve your dynamic data to EPiServer is to write your own custom content provider. You can find documentation here: http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/7/Content-Providers/Content-Providers/
This solution requires more coding and is more complex, but it has some benefits as well. If one wanted, it would be possible to not just serve content from external data source, but also update that data by changing values directly in EPiServer UI.
I've just started to learn symfony 2, and I have a small question
For example I have a site with articles. I want to show the total number of articles on every page, but every page is generated by some bundle.
So I need kind of some common script to do initialization of main variables, such as articles count.
How should I do it?
A simple way to achieve this is to have an action that fetches and outputs the total number of articles. You can then render that action from within other views (ex: $view['actions']->render('ArticlesBundle:Articles:getCount')). If you want this displayed on every page of your site, I would recommend rendering it from within your base.html.php view (or base.html.twig depending on which templating engine you're using). I'd also recommend caching it somehow, so you're not constantly hitting the database for a count that may not change very often.
See the docs on Embedding Controllers for more detail.
You can further expand on this example to define other 'main variables' that you want to use throughout your site. One idea is to define a service object whose purpose is to hold these variables, and then access its contents when you need to.
By the way, the title of your question is not descriptive of your problem, please consider rephrasing it.
A customer of mines wants the ability in their Drupal site to set some variables which they will embed in content. You know, things like number of customers, number of branches and so on. This way, when they update the variable values, the changes ripple throughout the site without them having to go and update a bunch of pages.
Have any of you come across a module which can handle this?
Many thanks
Froogle.
Token combined with Token Filter - it's fairly easy to setup your own tokens and instruct your content managers on how to use them using the Token Filter module.