Adding customizable Text to a Magento Page - javascript

I've been tasked with trying to add a message to the Product Compare Page which will appear if the customer has, by some stroke of stupidity, been able to access the page when there are no products to compare
now i understand there a <script type="text/javascript">window.close();</script> already in there however it seems like it doesn't work if you open a new window and type in the URL (the equivalent to bookmarking the page, how i figure is that if i put this message above the <script type="text/javascript">window.close();</script> line, if the window doesn't close the customer will get the message.
Now that part is easy enough, the hard part is the second part to my task and that's allowing this text to be changeable though the blackened much like how you can change the Logo Image Alt in System > Configuration > Design > Header.
we already have some new section in System > Configuration thanks to some custom modules however i don't want to have to create an entire module just so a department we can't trust to edited the page and not stuff it up in the process can change one line of text
So is there a way to add customizable Text to a Magento Page

You could change the javascript to window.location = '/sorry-page'; or something like that and creat "sorry-page` as a CMS page. Otherwise you will need a custom module.

Related

Is it possible to ignore CSS with a style or script?

We are using a shared platform for our website, so we don't have access to the base HTMl and CSS for the site, as it is global for all of their customers.
Currently, when you go to a brand page, you get the logo and a Read More link which expands the top area of the page and displays all of the about the brand information.
I really want to display this area by default and optionally hide it, if possible. Otherwise, just display it. But since I can't get to the base code, I can't figure out how to do it.
While I can't get to the CSS for the page/site, I can use styles or scripts.
Can anyone help? Here's a bit of the code. Essentially, I want the "read more" to go away and display the hidden stuff by default. I just can't get to the base code to do it. I hope that makes sense.
<div class="show-read-more">
<strong>About:</strong><br>
******* STUFF GOES HERE THAT'S HIDDEN NOW ******
<span class="read-more-span">
Read More
</span>
The general solution would be
Make a XMLHttpRequest to the platform
Use DOMParser() to load the platform as DOM
Manipulate the loaded DOM as you wish (add/remove styles or elements)
Display the altered DOM
If the platform has some CORS protection (so the XHR won't pass), you will probably need to make CURL request from your backend.

Edit existing items in a Wordpress theme

I've created a homepage, that simply has a sentence as the content
I've edited the settings so that this the front page of the website.
However, given the theme that I am using, when I go to the home page, this is what I see
I can see the content of my home page at the very bottom, but before that, there is a slider and a couple of blocks (that presumably come with the theme).
I'd like to know either how to remove these default blocks, or edit them myself to include links to other pages.
Also, as you can probably tell, I am very new to Wordpress. Are there any good documentations for beginners that would teach me how to create pages, edit and customize them so that I can have control over the whole page (as a regular website)?
I think you should edit by the php file, so if u don't know PHP start here.
Go to : menu > appereance > editor.
Here u see all the files you need. The file you should edit change with the theme.. so go through the code.
Maybe, it's under header.php
The html code you get above your content is inserted from the page template assigned to your homepage. Thus, if you want to modify it somehow you should go Editor Panel in Appearance Menu, then edit desired template. You can also create your own template with structure you actually want and assign it to that page.
As for a documentation, I think you're going to be good with the official one.
You can edit it by going appearence->editor with php code, be careful when you doing this
if you want to edit a header, you can find header.php in that particular theme
same with footer.php and you customize the design by clicking appearance->customize

Insert html pages into wordpress

I have an html site with a page of info for each county in the US. I want to convert this into a new wordpress site. I can do this one by one but my issue comes when I have mass changes to affiliate code or common text. I would have to got to each page and manually change it. but with over 3000 pages it would be way to time consuming. I dont want to use Iframes but would like to know if there is a way to call the html pages into the wordpress page that makes sense seo wise.
I am open to creating a page for each county or have one page with text or buttons on it with each county listed and when clicked will insert the info below. I know alot about static html coding but am new to php.
If you dont want Iframes, I think there only remain two options. I don't know if they will work in WordPress though.
1. PHP Include
With the very simple PHP include() statement, you can include the old html files in your new website. If you have a HTML-file for example, name your file yourname.php and add this in the position you want your old page to appear:
<?php include(path_to_old_page/name.html); ?>
This will include the full old page, but the file needs to be on the same server.
2. AJAX
With JavaScript you can perform XHTTP-requests to load files from the server. This is easiest when using jQuery. Here you can use the $(selector).load(path_to_old_page/name.html) statement. This will load the file in the HTML elements to which the selector applies.
(The selector works the same as CSS selectors, see the w3schools page for more)
This will also include the full old page, when it is on the same server
You can have your static pages in WordPress as well. Like if you want to create a new county named "example" you can create new WordPress page named "example" by entering title " example" .... now come to content. Just copy page content (only "example" county related html code from your static website) and place that code inside newly created WordPress "example" page. Make sure you add this html content inside 'text' tab in editor. Your page will be created with all your existing data ... now you can view this page and can use this page's URL where ever you want.

Trying to load page into div, but div showing too small

I'm trying to build a page where the admin can do multiple tasks from within.
For example after the admin logs in, he will click on a button to either manage the users or view the reports, but the result the result is extremely small view of the page while I'd like the loaded page to fill the entire bottom of the screen:
here is my code:
I looked for explanation on the web but couldn't find any.
Thanks.
The size of the element you're looking at is probably the default size for an object in that browser.
You're putting your file/data directly into an object with type text/html; to be honest, I'd suggest looking into a bit more background information on how to display data on the web using tables and/or grids without actually dumping pure file-info into the client-window.
I fixed the problem by using iframe. Thanks

How to stop Google from using a Javascript loaded greeting from being used as meta desciption

I have a Javascript greeting that greets new users with a drop down banner like SO has. It only becomes visible after 3 seconds and when the X is clicked it disappears. Since I have not put meta description tags, on every page Google shows that greeting as the meta data. I dont understand why Google is using this seeing as it is not loaded staight away, will this stop happening if i use meta description?
Should I use Meta desciption? On the upside it might help this problem, but then Google wont be able to dynamically fetch data from the site (which happens to be a forum). It so happens that it is doing this anyway and I dont know why?
Thanks!
My best guess is the text from your greeting is being added to the page (a wordpress plugin?) on the server side as visible (so it appears even if javascript is disabled), hidden by javascript on pageload, then just being shown after 3 seconds (i.e. it is really there already and as such is the first major text google finds).
Try changing your greeting plugin/code to generate the div containing the greeting message after page-load, or at least to append it to the end of the document (or apply style="display:none;" as an inline-style so Google can see it) on the server-side then tweak the js to show it. It would no longer greet visitors with js disabled, but would also allow google to reach your main content without encountering the greeting.
It does this because it's the first readable bit of text found when parsing the DOM. I'm not sure if there is a delay google uses before it saves the page state to its cache but that shouldn't matter. I actually use this 'feature' of google to allow me to manipulate what the site listing says in the search listings. If you want it not to show up just move the code for the message to the bottom of your <body>s node list (i.e. put it just before you close the </body>).
display:none won't do anything it has to be moved so that it's not in the first few readable lines of text when the DOM node tree is parsed.

Categories