I have the following problem, I have a template layout.html.twig which is loaded everywhere, in it I have a menu with categories downloaded from the database, and now my question is how to make a list of categories from the database in each controller from the machine, instead of each time download a category repository and all categories from it. I have been working in Symfony for a long time, but I create the API without views, hence the problem. Generally, I would like that after loading layout.html.twig a list of categories has been downloaded without my intervention, bypassing the loading of this list in every action of the controller.
I have fixed elements on the site, such as: category menu downloaded from the database, on the main page I have popular articles that also have to be on every subpage, and it makes no sense to download everything in every controller every time.
Any ideas?
I would create a menuFragment method in my DefaultController, and use a sub-request to render it.
https://symfony.com/doc/current/templating/embedding_controllers.html
Some people will tell you that sub requests slow down your code, but it is not significant if you don't go overboard with it. 1-3 subrequest won't be a problem at all.
Related
there is this site https://www.delinski.at/ and it has a nice form where you can pick some values from dropdowns like Date, Number of Persons etc., and then submit the form. It redirects and I see the values on the redirected page link as parameters (if I have changed the defaults).
I searched for and tried several Form Plugins which all do not seem to work - most recent one (Form Maker) lets me design the form as I want but at the end I realized when I click on Submit, the values are not transfered to the target page (confirmed by Form Maker Support as work as intended). It's confusing because actually that should be a basic funciontality of a HTML form, right?
So I want to know if there are plugins where I can get a similar look&feel like the example given above.
That site is a Static Site Generated framework not WordPress. That site would also be very expensive to build cause that is all coded, and very well:)
You are not actually seeing a form there at all that is just how PHP natively uses the URL to navigate via a button.
Almost all the form plug ins for WP use the database write now and do not pass the parameters of the entered form as a php _ POST with a redirect.
I kind of think what you really are looking for is a faceted search feature
One of the best that comes to my mind is https://facetwp.com/demo/cars/?_vehicle_type=truck
Notice the car icons those are actually search buttons:) Of course you will have to build a template to do that neat stuff on the SSG site you linked but...
here is a really informative write upon how it works to get started.
I might need to provide a lot more information for anybody to give me any meaningful feedback, but let me first attempt to describe the issue.
I have an app that lists items for sale. Each item has an individual unique page in my app, but the same template is used for rendering each of those pages. The first item page I load up is rendered perfectly. The same is true for the second page, but because the template has already been used to render an item before, I get a brief flash of the content (images and text) from the previous item.
Obviously, this could be an issue with me setting reactive variables after the template is rendered, but since I specifically destroy all reactive data associated with the template when I navigate away from the page, I am more inclined to believe that this is an issue with how a template is re-used by meteor. I would assume that the template is cleared of all previous data before it is re-inserted into the DOM, but that does not seem to be the case.
Anybody have any experience with this type of issue?
I'm building a website that on its frontpage has different 'lists' of stories/articles.
You can compare it to Wordpress 'latest articles', 'spotlight articles' etc.
Now every list needs to be created, and filled from the repository.
Which means, that in my controller, I first create/retrieve all the lists, add them to the ViewBag, and then return the view.
In the View i'll then foreach over the items in that list to create a visual list to be shown on the frontpage.
However, when I load the page, I first get a blank page, when the page is loaded, and then at one point everything appears.
Traditionally, you would already see the basic html, text etc, and then the dynamic area's would appear later.
Is it possible to have a similar 'progressive loading' with MVC3?
Its not so much the performance I'm worrying about but more so the user experience of seeing a blank page for several seconds on data-heavy pages.
Thanks :)
If you've got heavy pages with long loading times you might consider loading the pieces more dynamically using an ajax approach.
Your page loads, you execute the requests for the data you require and use some standard loading icon in the meantime.
Does anyone have any ideas or know of any plugins to allow pages to be scheduled and replaced.
preamble:
currently evaluating different content management systems for a new project, we create new pages and also updating existing pages for example as part of a 'maintenance release'.
We will be using either PHP (preferably) or C#
Problem:
We would like our users to be write and save a new revision of an existing page with a go-live date and time in the future, at this date and time we would like the page to be live replacing the existing page, but all links to the page, url etc to be the same.
Currently:
We have two separate installs and schedule updates to pages using a cron job and a PHP script running some mysql queries - this has failed us at critical times in the past when it has failed to run.
finally:
We could probably write this ourselves, either in our own CMS or as a plugin to an existing CMS - simply:
SELECT latest_revision from posts_pages_table
WHERE publishable='yes'
AND max(revision_date);
but does anyone have any experience of this with an existing CMS or from a technical point of view foresee any problems?
How for example in a wordpress backend will a user be sure they are updating the latest version of a page if it hasn't gone 'live' yet.
We have looked at all existing CMSs and searched google but scheduling updates to pages seems to be an uncommon occurrence so relying on some guidance from the trusty SO crowd.
thanks
If you are fine with PHP, you can use SilverStripe. To achieve what you are asking you'd use the CMS Workflow module.
SilverStripe CMS comes with two stages built-in: live and draft. You can keep reworking the draft version, which remain private until you are ready to publish. In the normal scenario you would just push to live.
With the CMS Workflow installed, you can additionally choose the date when the modification should go live ("embargo"). This stores your draft version for "later", and only pushes to live at the date you've chosen (this plugs in via the cron job).
There is also an "expiry" you can set on the page, at which point the page will be unpublished and will no longer be available publicly.
Embargo, expiry and publishing operations do not affect the URL nor ID of the page, so all the relations stay intact while you are reworking the page via the CMS.
References:
PDF manual, see page 16 for description of the embargo
Module page with a short description
Source
In Joomla, there is a way to do this out of the box without touching any code. Here's how I would do it -
Create a category for the page that will be getting replaced
Create a menu item pointing to that category. Set it to display 1 item only, ordered by newest date
Create a template override so that the category item displays like an article detail page
Create new articles with a start publish date that determines when it starts displaying
Basically, you'd be displaying a category but it would look like an article. It would always pull the newest article that has reached it's start publish date. It would be easy to keep track of because you would have copies of every version you post, each update you would simply make a copy of the last one to edit.
You could probably write something custom to accomplish the same thing, but why spend the time and effort when it can be done easily with a template override?
I have recently created an application where a lot of data is loaded into objects when the application starts up, and other data as it is required. For example if the user requests the catalogue page then it will load all the top level category data into objects of type Category. This will then stay there to be used by other users (who will therefore not have to load this data into objects) and can be altered by admin if they happen to login during the same application instance. I know this is not the most efficient solution, as pointed out below, but it works and the page load, at the moment, is not too long. It is very quick if most of the required data is already loaded into objects. It is also tailored to the business' needs - unlike other techniques such as Linq-to-SQL.
The problem I am facing is when a page is requested which requires lots of data to be displayed about different types of object. For example when a catalogue page is requested which displays information on a product which can be bought, it then loads all the products and categories (as the products make reference to the category object, not just the category name).
I would like to display a loading symbol with a message whilst all this data is being loaded into objects, so the user knows its not just in a loop or anything. Is there any way to do this? I am open to using JS / jQuery if I need to.
Thanks in advance.
Regards,
Richard
PS I am working on ways to make it more efficient - such as using HashTables or HashMaps. However this is taking time as there are so many different types of item (News, Events, Catalogue Item - Range, Collection, Design, RangeCollection, CollectionDesign, RangeCollectionDesign and RangeDesign - Users, PageViews and the list goes on).
Please correct me if I'm wrong, but I do believe that Javascript is required in order to display a "loading" image... Using server-side scriping alone would typically require an entire page load after all the content loads unless you want to start messing with IFrames.
This is a job for AJAX. A common solution to your problem is to have a small page that displays a loading icon. The page has some JavaScript that makes additional HTTP requests to the server to download the rest of the page. JQuery has a "$.ajax" method that is designed to simplify this process.
I would suggest looking at the documentation to the .ajax method in the jQuery documentation. Unfortunately, it seems to be a rather delicate process to get all the scripting code right and it takes a while to learn it all.