Moderator
t-p
(@t-p)
Is a WP PAGE a Server Side Wiget or is it a BROWSER/Client Side Widget?
Are you referring to a plugin by the name WP Page Widget?
If so, I recommend asking at https://wordpress.org/support/plugin/wp-page-widget so the plugin’s developers and support community can help you with this.
Thanks
The PAGES Text/Visual appears to be a WP native Dashboard feature (PAGE vs POST) … uses wp-content/themes/<some_theme>/page.php as its template … If I drop a line of HTML source or a shortcode on the PAGE, the entry is turned in to a fully formatted HTML page when the Client browser connects. That part of the process is clearly a Server Side process … what isn’t clear is if Form, shortcodes or HTML are NAILED up (connected) to the Server Side via some background AJAX process or if there needs to be some Special code to set up a Call back function to pass back and forth data.
Installed MAMP under windows along with the latest version of WordPress with NO plugins installed and PAGES is part of the generic WP Dashboard.
WP appears to have an API which might be something to explore further.
Moderator
t-p
(@t-p)
Sorry, I don’t quite follow.
Hope somebody else can chime in.
Neil
(@neilgilmour)
WCLDN 2018 Contributor
It sounds like you know your stuff vycwebmaster, but perhaps you’re trying to do something ‘your way’ rather than ‘the WordPress way’?
Could you explain what you’re trying to do with real context rather than input fields and output fields. We could spend ages helping with your solution, but it may not be the right solution to your problem. I believe this is sometimes referred to as the x/y problem.
Remember that WordPress out of the box is designed to be used by people who don’t necessarily know what a database is, or how to write values to it. You can certainly still do this in a WordPress site, and just like with any other tool you’ve used there’s some reading to do first to get up and running. Check out the Codex for WordPress documentation. There’s a good explanation of the database in there too.
If you’re looking to build an application inside WP, then something like ProdPress or Pods may help.
But I say again – let us know what you’re trying to achieve and you might find that someone has already done it and you don’t need to re-invent the wheel…
Thx for the responses everyone … truly not trying to reinvent a wheel, yet, seems like 40+ years of so called software progress, from my chair, things truly haven’t changed with regards to getting stuff right … I am resorting to look under the hood because after spending countless hours trying numerous plugins, nothing I tried would do even the simplest action of just looking up an entered value and returning a result … after a few days of bashing away at this, I believe I have found the answers to most of my questions:
1) all wordpress pages are treated as posts with all content contained in SQL tables
2) embedded short codes trigger WP to let plugins inject their view of the world
3) when a page is requested, WP builds a dynamic folder as wp/<dynamic page folder> then builds an html page based on the content of the page record using that dynamic folder for the pages url … a high level:
– the page record does appear to allow; HTML, PHP, JQUERY, JS, AJAX etc. commands (although this appears to come with some hidden restrictions)
– WP appears to take control over things like url content so for example a raw jquery load() will not accept an absolute url (proved this by reviewing the unix logs) … to actually use the load(), one has to use relative url references … so if you were needing to run or access a file stored in wp/somefolder/somefile.txt you would need to reference it as ../somefolder/somefile.txt
4) from past experience, all client side interaction with server side processes and data is best handled via AJAX call back functions … so … without using a plugin, that will require investing a bit more time playing with something like jquery’s AJAX interface.
Perhaps WP would benefit from a library of things
Ok ‘UNCLE’! still struggling with WP page functionality:
A simple jquery example that dynamically adds rows to a form works as designed outside WP but fails to work from inside WP (when coded in MAMP index.php this allows dynamically adding 5 rows … HOWEVER … from a MAMP WP page, this content does nothing) … the expectation is the #add jquery code should be a client side action which appears to be supported by the content of the viewed client source.
There are numerous discussions about adding jquery functions to a theme’s functions.php file by both registering and enqueing them … I expect all theme processing would be related to server side so not following the need to enque a client side action. I ran a simple test that shows the $(‘#<field>’).val() jquery command works in WP so perhaps the append() command needs to be modified slightly to work with the associated WP page?
<html>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script>
$(document).ready(function(e){
// vars
var p = '<p /><div> Test: <input type="text" name="Test" id="childTest" /> <a href="#" id='remove'> - </a></div>';
var m = 5;
var c = 1;
// add
$("#add").click(function(e){
if(c <= m){
$("#container").append(p);
c++;
}
}
); // add
// remove
$("#container").on('click','#remove',function(e){
$(this).parent('div').remove();
c--;
}
); // remove
}
); // document
</script>
<p />
<div id="container">
Test: <input type="text" name="Test" id="Test" /> <a href="#" id="add"> + </a>
</div>
</html>
var P source code (interpreted by the WP Dashboard editor) may be the issue for this example … may be the <p /> is being misinterpreted by the WP Editor … The PAGE source code shows
var p = '</p>
<p />
<div> Test: <input type="text" name="Test" id="childTest" /> <a href="#" id="remove"> - </a></div>
<p>';
which isn’t what was coded.
Neil
(@neilgilmour)
WCLDN 2018 Contributor
Ok, I’m not sure what you’re talking about now. Are you writing code in the editor
What are you trying to achieve? What will your visitors get from your website?
Could you explain what you’re trying to do with real context rather than input fields and output fields. We could spend ages helping with your solution, but it may not be the right solution to your problem. I believe this is sometimes referred to as the x/y problem.
If you’re doing this purely as a learning exercise then I suggest you start with the codex and then once you have a better grip of what WordPress is and does, feel free to pop back here or somewhere like StackExchange.
This example was coded in the pages editor (Dashboard New Page) … The project is to augment an online membership form built in VFB Pro that requires the ability to have:
1) 1 or more Contact details for both Primary and Secondary Members
dynamic rows of: Member, Contact Type, and Contact Detail
2) 1 or more Interest details for both Primary and Secondary Members
dynamic rows of: Member, Interest Type, and Interest Detail
3) 0 or more Tertiary Members
dynamic rows of: Name, Year of Birth
Primary: Name, YOB, Photo, Profession, Profession Status, Contact(s), Interest(s)
Secondary: Name, YOB, Photo, Profession, Profession Status, Contact(s), Interest(s)
Tertiary: Name(s), YOB(s)
My observation of the mangled variable was on the right track … the WordPress Page editor/parser wants to wrap everything you enter in the page editor with HTML “paragraph” tags … WP provides a way to get around this by enclosing
<script> blah </script>
with
<pre> blah </pre>
which tells the parser to use the content raw
Note: tried an HTML raw plugin but it didn’t seem to work using
<raw> blah </raw>
Note also: found that jQuery must be used in place of $ inside a WP Page, which from what I read, should use the “current” jQuery library.
My test code now runs as designed when enclosed with “PRE” tag. … Perhaps WP should include the PRE tag as an option in the HTML(text) view of PAGES?
-
This reply was modified 7 years, 6 months ago by
vycwebmaster.