On 2011-06-06, Wim Dumon <[email protected]> wrote: > 2011/6/6 Georg Sauthoff <[email protected]>:
>> Googling a bit, I assume that Wt does not really provides the means to >> support named-anchor navigation. > Go to the homepage, click on blog, then on a 'read more' link, and > you'll see that Wt skips the first part and goes to the extended > content part. I am trying that: Using Firefox 3.6 I click on 'Blog' and I get 'http://www.webtoolkit.eu/wt#/blog' - at that URL I see some 'Read the rest of this post >>' links. Clicking on the first I get a new page: 'http://www.webtoolkit.eu/wt#/blog/2011/04/08/wt_3_1_9__jwt_3_1_9/more' and this page is correctly scrolled down (skipping the teaser). With chromium 11 this works the same, except the displayed urls does not contain the '#' sign. > I haven't written that code, but I guess the trick is to manually set > the id of the div you want to jump to to the internal path, so that > the browser scrolls to that location. Indeed, using 'Inspect Element' in Chromium there is a div with special id: <div id="/blog/2011/04/08/wt_3_1_9__jwt_3_1_9/more"> The source of the blog is available in the source distribution of Wt: Wt-3.1.9/examples/blog In view/PostView.C (line 60) the div id is constructed: format(result, "<div>" + post_->briefHtml + "</div>" "<div id=\"" + basePath_ + post_->permaLink() + "/more\">" "<div>" + post_->bodyHtml + "</div></div>", XHTMLUnsafeText); In line 98 is the anchor to this id constructed (which is displayed on the overview page): WAnchor *moreAnchor = new WAnchor(""); moreAnchor->setText(tr("blog-read-more")); moreAnchor->setRefInternalPath(basePath_ + post_->permaLink() + "/more"); bindWidget("read-more", moreAnchor); The PostView class derives WTemplate, btw. Ok, using this information I modify my previous example, trying to create a minimal example: #include <Wt/WApplication> #include <Wt/WLogger> #include <Wt/WAnchor> #include <Wt/WText> #include <string> using namespace Wt; using namespace std; class Main : public WApplication { private: WText *named_; public: Main(const WEnvironment &e) : WApplication(e) { log("info") << "Constructing new session"; WAnchor *x = new WAnchor("", "Jump to the middle", root()); x->setRefInternalPath("/my_anchor"); for (size_t i = 0; i < 500; ++i) { WContainerWidget *a = new WContainerWidget(root()); WText *t = new WText(a); t->setText("Hello World"); } named_ = new WText(root()); named_->setTextFormat(XHTMLUnsafeText); named_->setText("<div id=\"/my_anchor\"></div>"); for (size_t i = 0; i < 500; ++i) { WContainerWidget *a = new WContainerWidget(root()); WText *t = new WText(a); t->setText("end"); } } }; Wt::WApplication *create_app(const Wt::WEnvironment& env) { return new Main(env); } int main(int argc, char **argv) { return WRun(argc, argv, &create_app); } Using Wt 3.1.9 and this command line ./link.wt --docroot='.;resources' --deploy-path '/' --http-address 127.0.0.1 --http-port 8080 the scrolling only works with Firefox 3.6. With Chromium just a new session is created (== page reload) when the link is clicked. Any ideas how to fix this minimal example for Chromium? The CMakeLists.txt looks like this: cmake_minimum_required(VERSION 2.8) set(CMAKE_VERBOSE_MAKEFILE on) LINK_DIRECTORIES(/mnt/juser/local/wt-3.1.9/lib) SET(EXAMPLES_CONNECTOR wthttp) ADD_EXECUTABLE(link.wt main.C) TARGET_LINK_LIBRARIES(link.wt ${EXAMPLES_CONNECTOR}) INCLUDE_DIRECTORIES(/mnt/juser/local/wt-3.1.9/include) Best regards Georg ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
